Discussion on lobsters: https://lobste.rs/s/oxjvv0/0_1_0_2

It’s not that Roc only supports base-10 arithmetic. It also supports the typical base-2 floating-point numbers, because in many situations the performance benefits are absolutely worth the cost of precision loss. What sets Roc apart is its choice of default; when you write decimal literals like 0.1 or 0.2 in Roc, by default they’re represented by a 128-bit fixed-point base-10 number that never loses precision, making it reasonable to use for calculations involving money.

In Roc, floats are opt-in rather than opt-out.

  • FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    5 months ago

    Sounds crazy but apparently it uses type inference to convert them to float anyway.

    Even so… the fact that 0.3 doesn’t mean 0.300000000 exactly seems a lot easier to deal with than the fact that real numbers can now easily overflow.