Re:A Programming Language for the Internet of Things [pdf]
by Twey on Sunday September 17, 2017 @07:24AM
(#15269135)
Doesn't have to be terribly inefficient if you're careful with your encoding. See e.g. https://en.m.wikipedia.org/wiki/Quote_notation
> For this project it is assumed that IoT devices do not have an FPU [...] real in Daspel is a signed two’s-complement 32-bit fixed point number. It uses 16 bits to represent the integer part and 16 bits to represent the fractional part.
That makes sense from an implementation point of view, but it could require a real shift in thinking for programmers, do to the extremely limited range.
If you don't have an FPU, another option could be to use rationals - a pair of half-size integers, where the value is the ratio between them. Has any language tried that? It's sort of simple, but inefficient (because there are many representations for the same value, eg 2/1 and 4/2), and you need to calculate lots of GCDs to prevent overflow. On the other hand, it can exactly represent base-ten fractions, which might be handy.