News for hackers. Stuff that matters.
Re:Understanding the x86's Decimal Adjust after Addition (DA... by msm_ on Tuesday January 31, 2023 @07:52AM (#34594449)
How do they represent real numbers? If anything, they represent rational numbers.

Also I think your answer is unnecessarily nitpicky. Sentence 'floats can't represent "simple" values like 0.1 (...)' is perfectly clear to everyone on HN, I hope. In fact, I disagree that changing "values" here to a more precise mathematical term would improve anything.

Re:Understanding the x86's Decimal Adjust after Addition (DA... by astrange on Tuesday January 31, 2023 @08:00AM (#34594510)
> How do they represent real numbers? If anything, they represent rational numbers.

That's an interesting philosophical question. Does M_PI represent a rational number?

(M_PI isn't mentioned in my copy of the C spec, unless I just can't find it.)

Re:Understanding the x86's Decimal Adjust after Addition (DA... by wadd1e on Tuesday January 31, 2023 @08:06AM (#34594561)
does it not have to represent a rational approximation of Pi? Real numbers in the set theoretic sense are defined as limits of Cauchy sequences[0], and since we can't quite store an infinite sequence, it has to be a finite approximation due to the limitations of the real world.

[0]: https://en.wikipedia.org/wiki/Cauchy_sequence

Re:Understanding the x86's Decimal Adjust after Addition (DA... by astrange on Tuesday January 31, 2023 @10:05AM (#34595906)
It does after it's assigned to a variable, but maybe it doesn't before that.
Re:Understanding the x86's Decimal Adjust after Addition (DA... by CamperBob2 on Tuesday January 31, 2023 @11:20AM (#34597143)
Rationals are a subset of the reals.
Re:Understanding the x86's Decimal Adjust after Addition (DA... by otabdeveloper4 on Wednesday February 01, 2023 @01:36AM (#34607225)
No current computing architecture provides primitives for dealing for rational numbers. (Which is why you need to roll your own implementation in software, so nobody bothers.)

But we have great native support for approximating real numbers instead. (Because computing is designed first and foremost to make numerical methods efficient.)

Re:Understanding the x86's Decimal Adjust after Addition (DA... by otabdeveloper4 on Wednesday February 01, 2023 @01:31AM (#34607204)
Floats are designed to be computationally and mathematically efficient approximations of the real numbers.

The exist so that trigonometry and logarithms work properly in numerical methods. (A vastly more important problem than getting '0.1' to print pretty on the screen.)

There is no such thing as a 'value' in mathematics, and fixating on 0.1 in particular is pointless.

tldr - everyone should learn the math behind this first.