Futurebasic/Language/Reference/octstring

OCT$ edit

Function edit

(+) Appearance (+) Standard (+) Console

Syntax edit

octalString$ = OCT$(expr)

Description edit

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 FB, 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.

Note: To convert a string of octal digits into an integer, use the following technique: ÊÊÊintVar = VAL&("&o" + octalString$) 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 edit

HEX$; BIN$; DEFSTR BYTE/WORD/LONG; VAL&