incubator-ooo-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 115798] DEC2BIN() and HEX2BIN(): support of more than 10 binary digits
Date Mon, 13 Feb 2012 15:50:44 GMT

orcmid <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #3 from orcmid <> 2012-02-13 15:50:44 UTC ---
I hate to say it, but the OpenFormula specification is quite strict about the
limitation of the text of the binary form being limited to 10 binary digits and
that it be for a signed two's-complement value.

  So BIN2DEC(0111111111) is the largest positive value and BIN2DEC(1000000000)
is the smallest (negative) value.  (BIN2DEC(1111111111) = -1).

Here's the relevant text:

"Converts given binary number into decimal equivalent, with the topmost 10th
digit being the sign bit (using a two's complement representation). If given
Text, the text is considered a binary number representation. If given a Number,
the digits of the number when printed as base 10 are considered the digits of
the equivalently-represented binary number."

I find that rather awful, but it is apparently an interoperablity requirement
and it is wired into the OpenFormula specification.

The weird thing about BIN2HEX is that the result is allowed to be up to 10
hexadecimal digits (still for a twos-complement value) even though the input is
restricted to 10 binary bits.  However, the desired number of hexadecimal
digits is an optional parameter.  There is this odd statement: "If the input
has its 10th bit on, the Digits argument is ignored; otherwise, the Digits
indicates the number of digits in the output, with leading 0 digits added as
necessary to bring it up to that number of digits."  So, for a negative input
(10th-bit on), it is not clear how many hexadecimal digits are produced in the
result (there being no default value for the Digits parameter).

So I would say, for OpenFormula, the behavior of BIN2DEC is not a bug.

Configure bugmail:
------- You are receiving this mail because: -------
You are on the CC list for the bug.

View raw message