I'm starting to learn QBASIC for while, but the first test is something I can't understand fully... There is a part about the y variable which is returning "inf" and I can't understand WHY...I searched up that in Google but its just showing "inf" error. If it IS an error at all, it should not run at all but the program is running beautifully. Here's the code :
Print "Hello World"
x = 123
Print x;
y = 123^210 * x
Print y
And here's the output :
Hello World
123 inf
Is it because The power's too much ?? It should show an error then, but the code's running perfectly...
The QBasic 1.1 Help file gives the following limits:
Maximum Minimum ---------------------- ----------------------- Variable-name length 40 characters 1 character String length 32,767 characters 0 characters Integers 32,767 -32,768 Long integers 2,147,483,647 -2,147,483,648 Single-precision numbers: Positive 3.402823E+38 2.802597E-45 Negative -2.802597E-45 -3.402823E+38 Double-precision numbers: Positive 1.79769313486231D+308 4.940656458412465D-324 Negative -4.940656458412465D-324 -1.79769313486231D+308
From: QBASIC 1.1 Help file Subsection: Name String and Number Limits
And in the Character set, we find that the <caret>-character represents the exponentiation as a mathematical operator.
Hence, the value 123^210
is, by far, larger than the maximum double-precision positive number which is 2^1023 × (1 + (1 − 2^−52))
2^1023 × (1 + (1 − 2^−52)) < (2^6)^210 = 2^1260 < 123^210 = (2^7-2^4-1)^210