Download it now!
Bug 45950 - DEC2BIN() and HEX2BIN(): support of more than 10 binary digits
Summary: DEC2BIN() and HEX2BIN(): support of more than 10 binary digits
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
(earliest affected)
3.5.0 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
Depends on:
Reported: 2012-02-12 02:52 UTC by Valerio Messina
Modified: 2015-08-24 15:35 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Valerio Messina 2012-02-12 02:52:24 UTC
DEC2BIN() and HEX2BIN(): support of more than 10 binary digits, like BASE() do.
While 10 digit are enough for decimal and hex numbers, 10 bit are very few for
a binary number. Consider that as two's complement representation, the range is
restricted to -512 / +511 only.
On the other side, as now BASE() do not support negative numbers, so there is
no solution to represent high negative numbers. Binary numbers should be supported up to 32 or 64 bit for DEC2BIN() and HEX2BIN(), while BASE() should support negative binary numbers.
I saw that OpenDocument Formula require 10 digit, but let implement more than
10 digit (say "implementation-defined"):
Comment 1 Valerio Messina 2012-02-12 10:09:37 UTC
for BASE() I opened
Comment 2 Valerio Messina 2012-02-16 04:42:30 UTC
We can make optional the second parameter for the number of digit (or the position of binary sign) like BASE() 3th parameter.
If this parameter is missing, default to 10 for backward compatibility.
The parameter should support up to 64 bit
Comment 3 sasha.libreoffice 2012-04-03 05:49:51 UTC
Thanks for new idea
in 3.5.1 dec2bin writes Err502 if argument is more than 511, and if 511 then produces 9 digits. Therefore not implemented yet.
Comment 4 Valerio Messina 2013-05-31 09:01:15 UTC
DEC2BIN() accept up to 10 as second argument and support two's complement representation, so results in range -512/+511 on 10 digits, 
HEX2BIN() accept up to 10 as second argument but do not support negative numbers, so 9 bits of results and 0 as MSb.

Apparentrly there is also another limitation with HEX2BIN() in current implementation:
the first argument must have no more than 10 hex digits (40 bit), also when the output would fit in 10 binary digits. For example converting:
"0000000001" (10 digits) result 1, but converting "00000000001" (11 digits) results Err:502.
Comment 5 Eike Rathke 2013-06-28 15:01:42 UTC
The number of digits is fixed because these functions stem from other existing spreadsheet implementations which is the reason why they are defined as this in OpenFormula. Introducing further parameters or even worse yet another "implementation defined" would have impacts on interoperability.

The only proper way would be to implement some new functions with yet to be defined behavior.
Comment 6 Joel Madero 2015-08-24 15:35:15 UTC
*** Bug 93627 has been marked as a duplicate of this bug. ***