3 ms·
This does kinda exist in Scheme and Racket: > (/ 1 10) 1/10 > (exact? (/ 1 10)) 1/10 > (/ 1.0 10.0) 0.1 > (exact? (/ 1.0 10.0))
by lifthrasiir 5y ago
This does kinda exist in Scheme and Racket:
> (/ 1 10)
1/10
> (exact? (/ 1 10))
1/10
> (/ 1.0 10.0)
0.1
> (exact? (/ 1.0 10.0))
#f
> (/ #e1.0 #e10.0) ; #e for "exact"
1/10
> (/ #i1 #i10) ; #i for "inexact"
0.1
As mentioned in HN before [1], Pyret (which has the same origin as Racket) went further and made the exact literal (now "Exactnum") default, so the inexact literal (now "Roughnum") always requires a preceding `~`.
[1] https://news.ycombinator.com/item?id=28263486 https://news.ycombinator.com/item?id=28263486