3 ms·
I feel lot of unintuitiveness of floats stems from inexact decimal literals. With hex literals the situation would be marginally clearer
by zokier 5y ago
I feel lot of unintuitiveness of floats stems from inexact decimal literals. With hex literals the situation would be marginally clearer
- deleted 5y ago[deleted]
- rbonvall 5y agoWhen I create my own programming language, the syntax for float literals will be: ≈3.14159
- enriquto 5y agoThis does not make sense: floating point numbers are not really "approximate". For example, small integer arithmetic using floats is guaranteed to be exact. Your language would be very confusing for this common use case.
- lifthrasiir 5y agoThis 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