Live data from Hacker News

0.30000000000000004

0.30000000000000004.com

71–80 of 422 posts

Re: 0.30000000000000004

#72

> It's actually pretty simple The explanation then goes on to be very complex. e.g. "it can only express fractions that use a prime factor of the base". Please don't say things like this when explaining things to people, it makes them feel stupid if it doesn't click with the first explanation. I suggest instead "It's actually rather interesting".

Thanks for this.

Yep, I've thrown 10,000 round house kicks and can teach you to do one. It's so easy.

In reality, it will be super awkward, possibly hurt, and you'll fall on your ass one or more times trying to do it.

Re: 0.30000000000000004

#73
post #32
post #17

I remember in college when we learned about this and I had the thought, "Why don't we just store the numerator and denominator?", and threw together a little C++ class complete with (then novel, to me) operator-overloads, which implemented the concept. I felt very proud of myself. Then years later I learned that it's a thing people actually use: https://en.wikipedia.org/wiki/Rational_data_type

But rationals are more expensive to compute with (compared to floating-point; this is another example of the trade-off between performance and accuracy.)

[deleted]

Re: 0.30000000000000004

#74

IEEE floating-point is disgusting. The non-determinism and illusion of accuracy is just wrong. I use integer or fixed-point decimal if at all possible. If the algorithm needs floats, I convert it to work with integer or fixed-point decimal instead. (Or if possible, I see the decimal point as a "rendering concern" and just do the math in integers and leave the view to put the decimal by whatever my selected precision…

IEEE is deterministic and (IMO) quite well thought-out. What specifically do you not like about it?

Re: 0.30000000000000004

#75
post #67
post #17

I remember in college when we learned about this and I had the thought, "Why don't we just store the numerator and denominator?", and threw together a little C++ class complete with (then novel, to me) operator-overloads, which implemented the concept. I felt very proud of myself. Then years later I learned that it's a thing people actually use: https://en.wikipedia.org/wiki/Rational_data_type

It's actually in use in many places, for things like handling currency and money, and for when you get funny corner cases involving rounding such numbers and pooling the change. Whenever I see someone handling currency in floats, something inside me wither and die a small death.

Currency handling is almost never done with rationals (numerator and denominator) and is frequently (and correctly so!) done with fixed or floating point decimal types.

Re: 0.30000000000000004

#76

IEEE floating-point is disgusting. The non-determinism and illusion of accuracy is just wrong. I use integer or fixed-point decimal if at all possible. If the algorithm needs floats, I convert it to work with integer or fixed-point decimal instead. (Or if possible, I see the decimal point as a "rendering concern" and just do the math in integers and leave the view to put the decimal by whatever my selected precision…

I agree with this view, there's nothing more disgusting than non-determinism. The way computers rely on assumptions for the accuracy of a floating number is one that's contrary to the principles of logical thinking.

Re: 0.30000000000000004

#78

IEEE floating-point is disgusting. The non-determinism and illusion of accuracy is just wrong. I use integer or fixed-point decimal if at all possible. If the algorithm needs floats, I convert it to work with integer or fixed-point decimal instead. (Or if possible, I see the decimal point as a "rendering concern" and just do the math in integers and leave the view to put the decimal by whatever my selected precision…

Depends on the field. 99.9000000001% of the time, the stuff I do is entirely insensitive to anything after the third decimal point. And for my use cases, IEEE 754 is a beautiful stroke of genius that handles almost everything I ask from it. That's generally the case for most applications. If it wasn't, it wouldn't be so overwhelmingly universally used.

But again, there are clearly plenty of use cases where it's insufficient, as you can vouch. I still don't think you can call it "disgusting", though.

Re: 0.30000000000000004

#79
post #67
post #17

I remember in college when we learned about this and I had the thought, "Why don't we just store the numerator and denominator?", and threw together a little C++ class complete with (then novel, to me) operator-overloads, which implemented the concept. I felt very proud of myself. Then years later I learned that it's a thing people actually use: https://en.wikipedia.org/wiki/Rational_data_type

It's actually in use in many places, for things like handling currency and money, and for when you get funny corner cases involving rounding such numbers and pooling the change. Whenever I see someone handling currency in floats, something inside me wither and die a small death.

I haven't worked in fintech but I've read that money is often represented (at least in storage) as plain integers, since for example US currency only ever goes to two decimal places. But I guess once you start operating on it you run into potential truncation unless you use rationals.

Re: 0.30000000000000004

#80

IEEE floating-point is disgusting. The non-determinism and illusion of accuracy is just wrong. I use integer or fixed-point decimal if at all possible. If the algorithm needs floats, I convert it to work with integer or fixed-point decimal instead. (Or if possible, I see the decimal point as a "rendering concern" and just do the math in integers and leave the view to put the decimal by whatever my selected precision…

[deleted]
Post reply on HN