[Libreoffice-bugs] [Bug 136801] BASIC: CInt("+2") returns 0

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Thu Sep 17 12:25:01 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=136801

--- Comment #3 from Wolfgang Jäger <jag at psilosoph.de> ---
(The teacher's remark:)
Even the subchapter 
5.3 Constant Numbers [of the current specification (Part 4)]
is incomplete and misleading. 
Firstly the semantic remark "..., negative numbers are positive numbers with a
prefix "-" (HYPHEN-MINUS, U+002D) operator." is neither well worded nor
acceptable as a replacement for the needed syntactical generator. 
Secondly The minus character isn't an operator when used as a sign to write a
negative number, but a syntactical part of the number itself. In the same way a
plus character may be interpreted if prefixed to an unsigned number. That it
has no effect in this case is irrelevant when syntax is addressed.

Calc accepts the following examples as formulas, e.g:
(1:) =5+-----+++-12.34
(2:) =5+-----+++ -12.34
(3:) =5------+++ +12.34
and any similar. 
A thorough description of the situation would require to distinguish 3
different roles of the plus and minus characters:
1. role: Sign like the last minus in (2:)
2. role: Unary operator
2. case "+": Identity semantics
2. case "-": ChangeSign semantics
2. explanation: All the plus or minus in the given example except the first one
and the last one in each line can be interpreted this way. Concerning the last
one there is a choice (if no whitespace is behind).
3. role: Binary operator 
3. explanation: Exactly the first plus or minus in every line is to interpret
this way.
Reading also a plus or minus immediately prefixed to an unsigned number as a
unary operator would not cahnge the result. Making this interpretation
mandatory would, however not leave any way to write a negative number as a
constant, since -5 (e.g.) would only exist as an expression then.  

BNF has means to implicitly decribe the preferred interpretation where not
undisputable anyway.

And: 
The Basic function IsNumeric actually behaves faultily regaring the "+" as a
sign (my above position applied).
Please note : 
IsNumeric("- 1") --> False is correct!
IsNumeric("-1,555,999") --> True (Locale dependent!) is very bad. 
IsNumeric("-1 555 999") --> False accomplishes this.
How can we get rid of the explicitly deprecated characters misused as
GroupSeparators?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200917/6b7dfdd7/attachment-0001.htm>


More information about the Libreoffice-bugs mailing list