Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When I create my own programming language, the syntax for float literals will be:

    ≈3.14159


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


This 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.


They are approximate in the sense that the float literal 1.1 is not equal to the real number 1.1.


I think it was a joke




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: