| Hazique35 (219) | ||||
I wrote a small program that inputs a number n. then does 2 to the power of n. I realized afterwards that I did not include the 'maths' header but it still worked? (using microsoft visual C++ 2010 express). Heres the code:
when i typed 78954675946789.58654, (to raise 2 to this power) I got this output:
Anyone understand why this would happen? I was just wondering. Thanks. | ||||
|
|
||||
| hamsterman (4435) | |
That's because floats, like any type has some fixed precision. You can only store a finite amount of numbers on a finite amount of memory. Unlike, say, int, floats don't wrap around. They have special values to mean "infinity" or "not a number".This thread shouldn't be in lounge though... | |
|
|
|
| Hazique35 (219) | |
|
ok thank you. Sorry... | |
|
|
|