Opened 6 years ago

# Grammar allows zero

Reported by: Owned by: dmcclean Simon Cox minor Version 2.2 help semantics, grammar

### Description

The UCUM 1.9 grammar (I'm not sure where to find any work-in-progress newer version, so I apologize if this has already been addressed) allows 0 to appear as a <digits>, and therefore as a <factor>.

It shouldn't be permitted as a <factor> because it doesn't have a multiplicative inverse. It's inclusion ruins the algebraic property noted in section 18 that "For each unit u ∈ U there is an inverse unit u-1 such that u · u-1 = 1. Thus, (U, ·) is an Abelian group."

### comment:1 Changed 6 years ago by Gunther Schadow

Yes, floating point number has an assumed definition as decimal with optional scientific notation. There are additional consideration that relate to the implicit specification of the number of significant digits. These issues have been discussed in another work (the HL7 v3 Data Types standard). We have tried to keep this outside the UCUM specification, because we might have to include standardization of real numbers in computer notation into UCUM.

You may use the Java floating point notation for an example. Most other languages, e.g., SQL are quite similar and differences occur only in edge cases.

In the writing of numbers internally we use some rules:

• if the number is precise, write the digits without any decimal point, and use the "e" exponent to scale it back. E.g. G = 9.80665 m/s2 (exact) we write as 980665e-5.
• if the number is estimated, write with decimal point, e.g., even if 100 is an estimate, we would write 100. or 1.00e2

But this is of interest only in the internal notation we might use in any formal data tables. The UCUM standard as published in text does not make that distinction.

### comment:2 Changed 6 years ago by Gunther Schadow

oops, wrong ticket. this was for #162

### comment:3 Changed 6 years ago by Gunther Schadow

oops, wrong ticket. this was for #162

### comment:4 Changed 6 years ago by Gunther Schadow

True, factor should be defined by a regex, perhaps, as [1-9][0-9]*.

### comment:5 Changed 9 months ago by Brenée Mitchell

Component: → help set to Simon Cox new → assigned

### comment:6 Changed 9 months ago by Simon Cox

Indeed, in version 2.1 https://ucum.org/ucum.html#section-Syntax-Rules it is still the case that the grammar allows for the factor to be zero. Here are the relevant pieces:

```<digit>	        ::=	“0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9”
<digits>	::=	<digit><digits> | <digit>
<factor>	::=	<digits>
```

In order to suppress this problem, it would be necessary to replace the above, with something like like

```<digit>	                ::=	“0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9”
<digits>	        ::=	<digit><digits> | <digit>
<non-zero-digit>	::=	“1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9”
<non-zero-digits>	::=	<non-zero-digit><digits> | <digit><non-zero-digit><digits> | <digit><digits><non-zero-digit> | <non-zero-digit>
<factor>	        ::=	<non-zero-digits>
```

### comment:7 Changed 5 months ago by Brenée Mitchell

Milestone: → Version 2.2
Note: See TracTickets for help on using tickets.