http://robertjliguori.blogspot.com/2017/02/does-10-equal-09999999999999999.html

- 2

`if (bigDecimal1.compareTo(bigDecimal2) != 0) ...`

rather than using <. It still shows not equal.

- 1

Campbell Ritchie wrote:No, they are not equal.

Actually, 0.9999...... (infinitely repeating 9's)

*is*equal to 1.

But the program in the blog is not really showing that, because it isn't working with the number 0.9999...... (infinitely repeating 9's), but with an approximation with a finite number of 9's.

[OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]

Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2

I haven't watched the video, but there are a couple of simple ways to show that 0.999... is exactly 1. The simplest relise on the fact that multiplication and division are inverse operations. If I divide by 2, then multiply by 2, i get back my original number. That is a fundamental property of multiplcation.

so, i can take a number...Say 1, and divide it by 3, then multiply that result by three, and i'm back to my original number.

1 / 3 = 0.33333....and on and on forever.

0.3333...and on and on forever * 3 is 0.9999....and on and on forever. And so it must equal 1.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

Yes, that is the problem. It should be possible to show that all finite sequences of multiple 9s after the decimal point do not equal 1.0.Jesper de Jong wrote:. . . (infinitely repeating 9's)

isequal to 1. . . . an approximation with a finite number of 9's. . . .

*Reductio ad absurdum*of assumption 1 under 4 and 5)

- 1

Campbell Ritchie wrote:Yes, that is the problem. It should be possible to show that all finite sequences of multiple 9s after the decimal point do not equal 1.0

it should be simpler than that.

1 - 0.<x nines> = 0.<(x-1) zeros>1

I think i have that right...

so if there is a non-zero difference between two number, they are not the same.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

*x*is ∞ however, 0.0...01 degenerates to 0.0 and the two numbers become mutually equal.

SCJP

Visit my download page

There is a mathematical proof that 0.‾9 is equal to 1, so there is no side to pick. It's just a fact.

*The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.*

Stephan van Hulst wrote:

There is a mathematical proof that 0.‾9 is equal to 1, so there is no side to pick. It's just a fact.

Yeah, there are lots of proofs out there -- including one using 9th grade algebra. So, most 14 and 15 year old children (in the U.S. that is, other countries may be younger) knows this fact...

Henry