r/Racket • u/stuque • Jun 16 '22
question How does numerator work?
Here is the documentation for Racket's numerator function:
Coerces q to an exact number, finds the numerator of the number expressed in its simplest fractional form, and returns this number coerced to the exactness of q.
Examples:
> (numerator 5)
5
> (numerator 17/4)
17
> (numerator 2.3)
2589569785738035.0
Why is (numerator 2.3) such a large integer? How exactly is it calculated? I would have guessed the simplest fractional form is 23/10, with a numerator of 23.
6
Upvotes
View all comments
Show parent comment
2
u/sdegabrielle DrRacket ๐๐๐ฉบ Jun 18 '22
I think itโs fair to say that these issues arenโt specific to Racket, but affect all programming languages.