HansV wrote: ↑07 Mar 2025, 13:07
Excel formats the cell in which you input $32.3 as currency because $ is the default currency symbol on your computer.
On my computer, $32.3 is treated as text, so the number format is General and the value is displayed left-aligned. If I enter €32.3, however, it is formatted as currency.
Thanks for this response, Hans.
I am working on Rob Van Gelder's code. Rob uses run-time variables
strDecimalSeparator and
strListSeparator and so on, so in that sense his code if flexible. My examples (I should have stated) were run on Excel2003 with North American settings.
Indeed $32.3 arrives as currency, but my thrust was towards something more general.
This paper says in part:-
3.3.1. Dates The appearance of date and time values in spreadsheets depends on the presentation settings of cells. Internally, date and time values are stored as positive floating point numbers with the integer portion representing the number of days since a Jan 0 1900 epoch and the fractional portion representing the portion of the day passed. For this reason, the grammar only parses numeric dates and times and these are not distinguishable from other numbers.
:slaps forehead: Of course! Dates are stored as numbers. It is Rs45,723.43

as I type this.
That led me to wonder just how much literal data we might key in that is stored as a number.
That led me to ponder who set these rules, and that made me think that it must be the client or project manager who decides what is allowed, and hence what I specify in the BNF grammar.
This rabbit hole has many trails, including "Why is 12.34E+2" acceptable as a numeric literal to Excel2003 but "12.34E+2.5" is not. I can see no mathematical reason NOT to allow a fractional exponent, and a BNF parser for mathematics in general might allow "12.34E+2.5". But in the real world, some human client decides what to pay for.
The dollar sign is interesting; it doubles as a currency sign for some of us but, I think for all of us it remains valuable in specifying absolute cell addresses. This led me to consider parsing tokens separately, with "$32.3" being parsed as two strings "$" and "32.3" rather than just treating it as a formatted number.
More later when/if I pop out the other side of the warren!
Cheers, Chris