Posted By
SVS on 2003-07-21
| BASIC quiz
What's the result of the following Basic line:?
PRINT INT(-3.1)
S\_/S
|
|
Posted By
Noro on 2003-07-21
| Re: BASIC quiz
31 °C
|
|
Posted By
MC on 2003-07-21
| Re: BASIC quiz
i think is should be -3. Or is it -4?
|
|
Posted By
MC on 2003-07-21
| Re: BASIC quiz
-4, shit
|
|
Posted By
MC on 2003-07-21
| Re: BASIC quiz
oops, i just ruined your quiz?
|
|
Posted By
Csabo on 2003-07-21
| Re: BASIC quiz
It does say -4. It seems to be rounding DOWN all the time, right? When rounding -3.1, we normally round UP to -3 (since -3 is more than -3.1). It's probably a feature, not a bug (or that's probably what the Commodore programmers would say )
|
|
Posted By
Gaia on 2003-07-21
| Re: BASIC quiz
It boils down to mathematics and has nothing to do with Commodore or Microsoft. The result of an integer (denoted by [-3.1] in this case) operation is the largest integer that is not greater than the original. Among negative numbers it's the other way round than one would expect, since -3 is greater than -4.
|
|
Posted By
Csabo on 2003-07-21
| Re: BASIC quiz
Okay, but then what about this: open Microsoft calculator on your Windows machine, type -3.1 and click Int. It rounds it to -3. Is that one then, that is exhibiting a major screw-up?
|
|
Posted By
Gaia on 2003-07-21
| Re: BASIC quiz
I'd say yes... It seems to do a TRUNC rather than a real INT You can check it in more serious programs like Openoffice Calc or Excel
|
|
Posted By
Crown on 2003-07-21
| Re: BASIC quiz
Well, you should check first what the button does before assuming something about it... Just right-click the Inv button, and select What's this, and read it... It does exactly what is written there....
|
|
Posted By
Csabo on 2003-07-21
| Re: BASIC quiz
In my Windows calculator there is no Inv button, but there's an Inv checkbox. I did right-click the Int button however, here's what that one says: "Displays the integer portion of a decimal value. To display the fractional portion of a decimal value, use Inv+Int. Keyboard equivalent = ;"
So we assumed that it would give us the integer portion, and the help also says it gives us the integer portion. One of us must be missing the point here... Or perhaps we're using different versions of the Windows calculator?
|
|
Posted By
SVS on 2003-07-22
| Re: BASIC quiz
OK the quiz is over. The right result is -4. See the original Plus/4 C16 manual under INT function. It honestly clarifies that the function round to the *lower* integer.
Study people...
|
|