←back to thread

Uncertain<T>

(nshipster.com)
444 points samtheprogram | 2 comments | | HN request time: 0s | source
Show context
layer8 ◴[] No.45055943[source]
Arguably Uncertain should be the default, and you should have to annotate a type as certain T when you are really certain. ;)
replies(2): >>45056272 #>>45056582 #
nine_k ◴[] No.45056582[source]
Only for physical measurements. For things like money, you should be pretty certain, often down to exact fractional cents.

It appears that a similar approach is implemented in some modern Fortran libraries.

replies(4): >>45057007 #>>45057078 #>>45057151 #>>45060359 #
1. random3 ◴[] No.45057151[source]
have you ever tried working computationally with money? Forget money, have you worked with floating points? There really isn't anything certain.
replies(1): >>45057195 #
2. nine_k ◴[] No.45057195[source]
Yes, I worked in a billing department. No, floats are emphatically not suitable for representing money, except the very rounded values in presentations.

Floats try to keep the relative error at bay, so their absolute precision varies greatly. You need to sum them starting with the smallest magnitude, and do many other subtle tricks, to limit rounding errors.