Hi.
You've probably discussed this before, but I've happened to see a result that looks anomalous.
If I take the square root of 25, for example, the result is different from the integer (INT) of the result itself. While if I do the result of the root minus the integer of the result itself, exactly 0 comes out.
I am attaching the program with which I tested the anomaly.
Why does this happen?
include "$/inc/console.inc"
dim b as double
while 2
printl "input a number: "
int a=input()
b = sqrt(a)
printl "a = " a
printl "b = SQRT(a) = " b
printl "INT(b) = " int(b)
if b=int(b) then
printl "1) b = int(b)"
else
printl "1) b <> int(b)"
end if
printl
if b - int(b) = 0 then
printl "2) b = int(b)"
else
printl "2) b <> int(b)"
end if
waitkey
loop
This is the result of the tests:
input a number: 25
a = 25
b = SQRT(a) = 5
INT(b) = 5
1) b <> int(b)
2) b = int(b)
input a number: 63
a = 63
b = SQRT(a) = 7.9372539331937721
INT(b) = 8
1) b <> int(b)
2) b <> int(b)
(same result, ok)