For example, if I convert the float type 2.0000000000 to int, the underlying storage should be 1.999999999999999. There is a precision limit, so when I convert this number to int, I think it will become 1 (the decimal part is discarded)
But after testing several languages, they are still correct (php, java, go, js)
php:
js:
go:
java:
2.0
can be accurately expressed by floating point numbers. There should be no problems with this numberDecimals are stored in scientific notation, not 1.999999..., they are processed during the forced transfer, not directly converted to a type
Generally speaking, converting low precision to high precision, such as int->float, when converting high precision to low precision, you will lose precision, and the data results may become very surprising.
A few classic examples
(int)(0.57 * 100)
(int)((0.1+0.7)*10)
It has no practical significance. If it really works like you think, the person who designed this language will definitely take it into consideration
Detailed understanding requires certain assembly principles, so don’t get too carried away
Can I ask where you downloaded this programming panel? It seems good