Representation Functions

Normally the output of calculations is given as a decimal value. You can use the Representation Functions to get results represented in another way Binary, Decimal, Hexadecimal, Octal or as a Fraction. The Representation Functions doesn't actually perform a calculation, they just specify the representation of the value in the Workarea.

Important for the representation of numbers in other numeral systems is the system variable Bytes and the option Show leading zeros.

More about numeral systems is explained on the page Numeral Systems. To get results in another representation by default you can change the System variable Representation.


Back to top

Overview

The following functions are available for other representations of your results.
Function Description Example
Bin(x) Give the output as a binary number,
a base-2 system

Bin(13)
       Ans = 0b1101
Dec(x) Give the output as a decimal value,
a base-10 system

Dec(13)
       Ans = 13
Hex(x) Give the output as a hexagonal number,
a base-16 system

Hex(200)
       Ans = 0xC8
Oct(x) Give the output as an octal number,
a base-8 system

Oct(13)
       Ans = 0o15
Fraction(x) The answer will be displayed as fraction when possible. Fraction(0.1875)
       Ans = 3/16
Back to top

Examples

'Examples of using Representation Functions

' Specify the type of representation by enclosing
' the line with a function Fraction, Bin, Dec, Hex or Oct

Fraction(0.4)
       Ans = 2/5
Fraction(0.125)
       Ans = 1/8
Fraction(2/5 + 3/7)
       Ans = 29/35

Bin(3 + 18 * 2)
       Ans = 0b100111

Hex(26)
       Ans = 0x1A
Hex(15)
       Ans = 0xF
Hex(255)
       Ans = 0xFF

Hex(65340)
       Ans = 0xFF3C
0xFF3C
       Ans = 65340

Oct(13)
       Ans = 0o15
Oct(120 + 5)
       Ans = 0o175


' The specification of the desired representation is lost when 
' you perform an operation after the conversion.
Bin(24 + 2)
       Ans = 0b11010
Bin(24) + 2
       Ans = 26


'the binary system has two symbols, "0" and "1", and counts as follows:
Bin(0)
       Ans = 0b0
Bin(1)
       Ans = 0b1
Bin(2)
       Ans = 0b10
Bin(3)
       Ans = 0b11
Bin(4)
       Ans = 0b100
Bin(5)
       Ans = 0b101
Bin(6)
       Ans = 0b110
Bin(7)
       Ans = 0b111
Bin(8)
       Ans = 0b1000
Bin(9)
       Ans = 0b1001
Bin(10)
       Ans = 0b1010
'etcetera ...
Back to top

See Also

Functions Overview, Numeral Systems, Settings