This question has already been answered:

var x,y:real; begin x:=123.456; y:=frac(x); write(y); end. 

As a result, prints 0.456000000000003.

Reported as a duplicate by Regent , Anton Shchyrov , Kromster , Denis Bubnov , ermak0ff 19 Feb '17 at 7:31 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    And the question is what? So far, I see only a judgment about the incorrect operation of a standard function that does not take into account the specifics of storing real numbers. - Regent

1 answer 1

There is no mistake here. It's just that the way of storing real numbers is based on the sum of fractions of the form 1/2 n , well, and your 0.456 is not 0.5, you will not decompose it beautifully :)

Output with fewer characters, and everything will be beautiful :)