1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 15:00:38 +00:00
QB64-PE/internal/help/OCT$.txt

59 lines
2.1 KiB
Plaintext
Raw Normal View History

2019-04-15 01:15:33 +00:00
The [[OCT$]] function returns the base-8 octal representation of an [[INTEGER]], [[LONG]] or [[_INTEGER64]] value as a [[STRING]].
{{PageSyntax}}
2019-04-15 01:15:33 +00:00
: {{Parameter|result$}} = [[OCT$]]({{Parameter|number}})
{{PageDescription}}
2019-04-15 01:15:33 +00:00
* The [[OCT$]] function returns the octal (base-8) representation of {{Parameter|number}}.
* {{Parameter|number}} can be any integer value.
* No leading space is returned.
2019-04-15 01:15:33 +00:00
* [[VAL]] can convert octal string values to decimal when the "&O" prefix is added.
2019-04-15 01:15:33 +00:00
{{PageExamples}}
''Example:'' Outputs all of the decimal, hexadecimal and octal digits:
{{CodeStart}}
2019-04-15 01:15:33 +00:00
LOCATE 2, 20: PRINT " Decimal | Hexadecimal | Octal "
LOCATE 3, 20: PRINT "---------+-------------+-------"
template$ = " ## | \\ | ## "
FOR n% = 0 TO 15
LOCATE 4 + n%, 20: {{Cl|PRINT USING}} template$; n%; {{Cl|HEX$}}(n%); VAL({{Cl|OCT$}}(n%))
NEXT n%
{{CodeEnd}}
2019-04-15 01:15:33 +00:00
: ''Note:'' The actual octal value is converted by [[VAL]] directly back to a numerical value by '''not using''' the "&H" prefix.
{{OutputStart}}
Decimal | Hexadecimal | Octal
---------+-------------+-------
0 | 0 | 0
1 | 1 | 1
2 | 2 | 2
3 | 3 | 3
4 | 4 | 4
5 | 5 | 5
6 | 6 | 6
7 | 7 | 7
8 | 8 | 10
9 | 9 | 11
10 | A | 12
11 | B | 13
12 | C | 14
13 | D | 15
14 | E | 16
15 | F | 17
{{OutputEnd}}
{{PageSeeAlso}}
* [[HEX$]], [[VAL]]
* [[&H]] {{text|(hexadecimal)}}, [[&O]] {{text|(octal)}}, [[&B]] {{text|(binary)}}
* [[Base Comparisons]]
2019-04-15 01:15:33 +00:00
{{PageNavigation}}
<