Difference between revisions of "Documentation/How Tos/Calc: DEC2BIN function"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Initial content)
 
(noted text input is OK)
Line 8: Line 8:
 
=== Syntax: ===
 
=== Syntax: ===
 
<tt>'''DEC2BIN(number; numdigits)'''</tt>
 
<tt>'''DEC2BIN(number; numdigits)'''</tt>
: returns a binary number as text, given the decimal whole number <tt>'''number'''</tt>, which must be between -512 and 511 inclusive.
+
: returns a binary number as text, given the decimal <tt>'''number'''</tt>, which must be between -512 and 511 inclusive, and may be text or a number.
  
: The output is binary number with up to ten bits in two's complement representation; positive numbers are 0 to 111111111 (nine bits representing 0 to 511 decimal) and negative numbers 1111111111 to 1000000000 (ten bits representing -1 to -512 decimal).
+
: The output is a binary number with up to ten bits in two's complement representation; positive numbers are 0 to 111111111 (nine bits representing 0 to 511 decimal) and negative numbers 1111111111 to 1000000000 (ten bits representing -1 to -512 decimal).
  
 
: <tt>'''numdigits'''</tt> is an optional number specifying the number of digits to return.
 
: <tt>'''numdigits'''</tt> is an optional number specifying the number of digits to return.
Line 17: Line 17:
 
<tt>'''DEC2BIN(9)'''</tt>
 
<tt>'''DEC2BIN(9)'''</tt>
 
: returns <tt>'''1001'''</tt> as text.
 
: returns <tt>'''1001'''</tt> as text.
 +
 +
<tt>'''DEC2BIN("9")'''</tt>
 +
: returns <tt>'''1001'''</tt> as text. <tt>'''DEC2BIN'''</tt> will accept a decimal number given as text.
  
 
<tt>'''DEC2BIN(9; 8)'''</tt>
 
<tt>'''DEC2BIN(9; 8)'''</tt>

Revision as of 19:00, 25 February 2008


DEC2BIN

Converts a decimal number to binary.

This function is only available if the Analysis AddIn is installed.

Syntax:

DEC2BIN(number; numdigits)

returns a binary number as text, given the decimal number, which must be between -512 and 511 inclusive, and may be text or a number.
The output is a binary number with up to ten bits in two's complement representation; positive numbers are 0 to 111111111 (nine bits representing 0 to 511 decimal) and negative numbers 1111111111 to 1000000000 (ten bits representing -1 to -512 decimal).
numdigits is an optional number specifying the number of digits to return.

Example:

DEC2BIN(9)

returns 1001 as text.

DEC2BIN("9")

returns 1001 as text. DEC2BIN will accept a decimal number given as text.

DEC2BIN(9; 8)

returns 00001001 as text. Leading zeroes have been added to make 8 diigts.

See also:

BIN2DEC, BIN2HEX, BIN2OCT, DEC2HEX, DEC2OCT, HEX2BIN, HEX2DEC, HEX2OCT, OCT2BIN, OCT2DEC, OCT2HEX

Number Conversion functions

Personal tools