I am a supporter of St. Joseph's hospice. If you find this site useful or if it helped you, consider a small donation to St. Joseph's, please.

Information on
St. Joseph's

JustGiving - Sponsor me now!

 

Longdec2bin

What is the binary representation (with bitlength = 256) of the decimal number -872362346234627834628734627834627834628? Don't ask Excel's built-in function dec2bin(). It cannot handle numbers greater than 511.
If you want to get the correct answer
1111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111101011011111011010100011111
1001110111100101111001000010000111010110010010100110011010001001100111101010
0001010101001011110011111100 then have a look at the functions listed below.

I intend to enhance the functionality. So far fractional parts are possible only for positive decimals which will be transformed into binaries by sbLongDec2Bin(). The decimal 0.5 is in binary format equal to 0.1, for example.

Function

Parameter 1

Parameter 2

Result

Comment

binneg

0

 

0

 

binneg

1

 

1111111111111111
1111111111111111

Implicite bitlength is 32

binneg

11111111111
11111111111
1111111111

 

1

 

binneg

10000000000
00000000000
0000000000

 

#VALUE!

Correct error value

binneg

0

2

0

 

binneg

1

2

11

 

binneg

11

2

1

 

binneg

10

2

#VALUE!

Correct error value

divby2

0

TRUE

0

 

divby2

2

TRUE

1

 

divby2

1024

TRUE

512

 

divby2

3.14159265

FALSE

1.570796325

 

divby2

0.5

FALSE

0.25

 

divby2

0.25

FALSE

0.125

 

divby2

0.125

FALSE

0.0625

 

decadd

0

0

0

 

decadd

0.0001

0.9999

1

 

decadd

123.456

987.654

1111.11

 

longdec2bin

2005

 

11111010101

 

longdec2bin

2005

11

#VALUE!

Now 2005 is too big

longdec2bin

11.5

 

1011.1

 

longdec2bin

2.25

 

10.01

 

longbin2dec

1111

 

15

 

longbin2dec

1111

4

-1

 

longbin2dec

11.11

 

3.75

 

20110321_PB_01_sbLongDec2Bin_Code

If you are interested in downloading a 45 KB Excel 2010 sample file go to my Download page, please.

20110321_PB_02_sbLongDec2Bin_Code
20110321_PB_03_sbLongDec2Bin_Code
20110321_PB_01_sbLongBin2Dec_Code
20110321_PB_02_sbLongBin2Dec_Code
20110321_PB_03_sbLongBin2Dec_Code
20110321_PB_01_sbDivBy2_Code
20110321_PB_02_sbDivBy2_Code
20110321_PB_01_sbBinNeg_Code
20110321_PB_02_sbBinNeg_Code
20110321_PB_01_sbDecAdd_Code
20110321_PB_02_sbDecAdd_Code
20110321_PB_03_sbDecAdd_Code