DECIMAL


Returns a decimal number, given a text representation and its base radix.

Syntax:

DECIMAL(text, radix)


text is text representing a number with the base radix radix (an integer between 2 and 36).

Any leading spaces and tabs are ignored.

Letters, if any, may be upper or lower case.

If radix is 16 (hexadecimal system), any leading 0x, 0X, x or X is ignored, as is any trailing h or H.

If radix is 2 (binary system), any trailing b or B is ignored.

Example:

DECIMAL("00FF", 16)

returns 255 as a number (hexadecimal system).

DECIMAL("101b", 2)

returns 5 as a number (binary system).


Application:

Let's imagine a system that processes data from old-school hardware, which sometimes outputs numbers in different bases. One specific piece of equipment, a vintage scientific calculator, records its results as a text string with an accompanying base. To use these results in modern financial calculations, we need to convert them into a standard decimal format.


Here is a simplified example of the data we might receive:

Text Representation

Base Radix

A
B
1
10110
2
2
A2F
16
3
177
8

The DECIMAL function would be used to convert each of these entries into a standard base-10 decimal number.


  • For the first row, the input is "10110" with a base of 2 (binary). The DECIMAL function would convert this to its base-10 equivalent, which is 22. (1⋅24+0⋅23+1⋅22+1⋅21+0⋅20=16+0+4+2+0=22)
  • For the second row, the input is "A2F" with a base of 16 (hexadecimal). The DECIMAL function would convert this to 2607. (10⋅162+2⋅161+15⋅160=10⋅256+2⋅16+15⋅1=2560+32+15=2607)
  • For the third row, the input is "177" with a base of 8 (octal). The DECIMAL function would convert this to 127. (1⋅82+7⋅81+7⋅80=1⋅64+7⋅8+7⋅1=64+56+7=127)


The final output, after applying the DECIMAL function to each entry, would be a new column containing the base-10 decimal values:

Text Representation

Base Radix

Decimal Value

A
B
C
1
10110
2
22
2
A2F
16
2607
3
177
8
127




This page is protected by Google reCAPTCHA. Privacy - Terms.
 
Built using Zapof