Changes

Jump to: navigation, search

Locomotive BASIC

43 bytes added, 09:14, 27 November 2013
/* Type Conversions */
== Type Conversions ==
The BASIC functions <code>ROUND</code>, <code>INT</code>, <code>CINT</code> and <code>FIX</code> can be used to convert real numbers into integers taking some care about rounding. The difference is in rounding mode - <code>ROUND</code> rounds to nearest, <code>FIX</code> rounds to zero, whereas <code>INT</code> always rounds down, and <code>CINT</code>rounds up. e.g., <code>value%=INT(3.14)</code>. Note that if you don't specify the % you will actually get a real number still.
To convert an integer to a real number, you can use the <code>UNT</code> function which will take the value supplied and return the two's complement number. e.g., <code>real=UNT(&ABCD)</code>.
17
edits