floating point alternatives

21 days ago by cm0002 to c/programming

load all comments
Ad4mWayn3 9 points 20 days ago

Not mentioning fixed point in an article about floating point alternatives is a sin. Unlike any of the alternatives listed here (yes, even floating point), if your computer can do integers, fixed-point comes practically builtin! it's literally the same machine instruction plus one or two bitwise shifts.

Decimal floating point is probably the worst of every world. Without specialized hardware, implementing floating point is pretty hard in software, and comparatively slow. Since internally the decimals are stored in binary, a shift in the exponent means you have to recompute the mantissa as if you did multiplication or division, so you also lose the advantages of binary :)

Fractions are probably the most practical implementation for arbitrary precision as they are base-agnostic, and thus, free of repeating fractionals. The problem is that you need to do lots of gcd and lcm for addition. I have never done a full implementation, but I'd say libraries represent them internally as mixed numbers, integer part and less-than-one fractional part.

Symbolic computation is really hard. I hope you know your data structures and graph traversals!

Interval arithmetic is niche and I didn't pay attention to the lecture on measure errors so I'm not very familiar, but wikipedia says binary operations between intervals is literally matching and min/maxxing so this one may have the second simplest software implementation.

For binary-coded decimal my guess is that decimal digits are stored as 4 bits each. Probably wasteful for any kind of arithmetic, so their use would mainly be conversions--after all, no matter how good binary is, people are used to decimal (which is not even that good of a base), and it's the computer's task to output that.

path: 0 25955862, hotness: undefined, score: 9, children: 0
programming
programming

@programming.dev

login for more options
28786
3717
3364

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev


go to feed...