>opens python3 shell
>this happens
Pls explain to this monkey what is happening or confirm that I am crazy or have some kind of schizofraenia. I am afraid that there are no 2 in the pic related an I'm just imaging it.
>opens python3 shell
>this happens
Pls explain to this monkey what is happening or confirm that I am crazy or have some kind of schizofraenia. I am afraid that there are no 2 in the pic related an I'm just imaging it.
Welcome to floating point numbers and how they are stored
Floating point can only represent so many values retard. You got too precise
Why haven't scientists or whatever created a system that stores floating point numbers precisely?
it's called double
Checked
picrel
They have this technology, just in different math related languages that are actually useful to scientists. Don't use python for math.
You mean EXTENDED?
Common Lisp does not have this problem
what about java
Ah, so its about how the value is being processed (stored) by the interpreter, not about int() function doing weird stuff. Sad thing is that I know how floating point numbers work, I am just that retarded. Guess I'll go to sleep.
Thx Anons this thread can die now.
t. a monkey
int() just converts floats to ints by rounding them towards zero
in the second case, you typed 1.999 etc but due to float imprecision the closest number that the float could represent was actually 2.0000000000001 or something like that, so it rounds to 2
Yes
When you enter a number it's rounded to the closest value that can be represented by the floating point scheme (usually IEEE754 binary64 or "double").
The representation is similar to how scientific notation numbers work, you represent values with a given number of significant figures.
Your first number probably rounded to something like 1.9999999999999998 and the second rounded to 2.0000000000000000 (exactly 2).
At most 17 significant digits are needed to print out a double so that it will be read back as the same number. Also, anything up to 15 significant digits can be converted *to* a double and then back again without changing the value to 15 significant digits.
0.999... = 1
Absolutely nothing to do with this
import numpy as np
>what is numPy
lol really Any Forums?
Floating point representation error. Floating point numbers are of limited precision, the latter is probably represented as something >=2 and as such when truncated into an int it returns 2 instead of 1.
Yeah, it's called using the right data type
user if you think that's bad try doing 7/3 in Python.
>2.3333333333333335
FROM WHENCE COMES THIS FIVE
>what is haskell