FutureBasic Logo

<<    Index    >> FutureBasic 5

oct$   function

octalPascalString = oct$(expr)

This function is a string of octal (base-8) digits which represent the integer value of expr. The returned string will consist of either 3, 6 or 11 characters, depending on which of defstr byte, defstr word or defstr long is currently in effect. Note that if the value of expr is too large to fit in the currently selected defstr size, the string returned by oct$ will not represent the true value of expr.
In FutureBasic, integers are stored in standard "2's-complement" format, and the values returnet by oct$ reflect this storage scheme. You need to keep this in mind when interpreting the results of oct$, especially when expr is a negative number. For example: oct$(-3) returns "775" when defstr byte is in effect; "777775" when DESTR word is in effect; and "77777777775" when defstr long is in effect.

To convert a string of octal digits into an integer, use the following technique:
   intVar = val&("&o" + octalPascalString)
intVar can be a (signed or unsigned) byte variable, short-integer variable or long-integer variable. See Appendix C - Data Types and Data Representation, to determine the range of values that can be stored in different types of integer variables.

See Also:
hex$; bin$; defstr byte/word/long; val&