LiteralUnlimitedNatural.UNLIMITED is not a number, it is an enumeration
literal, so it is distinct from all numbers.
"1" is the enumeration ordinal.
On 18/09/2011 09:40, Emil Huseynli wrote:
> Interesting, doing System.out.println LiteralUnlimitedNatural.UNLIMITED)
> gives 1, but if i do
> Property p = myAssociation.getAttribute("theAttribute");
> System.out.println (p.getUpperValue().stringValue())
> then * is printed. It's pretty ok for me, but still interesting what
> is the internal representation of the
> LiteralUnlimitedNatural.UNLIMITED. Maybe -1?
> On 18.09.2011 10:23, Emil Huseynli wrote:
>> Hi, i wonder why value of LiteralUnlimitedNatural.UNLIMITED is 1? Is it
>> normal? Shouldn't it be MAXINT or so?
Uh, it's not an enumeration literal and the value is -1, not 1. Because an unlimited natural is supposed to be a natural number (i.e., 0 or higher), the value of -1 is used as a special indicator to mean the maximum possible value. The same is done for upper bounds on Ecore features in EMF.
Oops. Yes. Not an Enumeration; sure I checked, but no.
The implementation of numbers is implementation-specific; MDT/UML2 opts
for Java's Integer.
The UML specification is genuinely unlimited and the equivalent Integer
implementation for MDT/OCL has attracted bug reports, so that the
traditional code now has some support for a Long range. The new Pivot
model implementation is IntegerValue which has polymorphic
* or UNLIMITED is really a misnomer for plus infinity. It is bigger than
MAXINT. -1 is clearly not bigger than MAXINT, so all code that accesses
an UnlimitedNatural must special case the out of bounds negative value.
On 12/10/2011 14:31, Kenn Hussey wrote:
> Uh, it's not an enumeration literal and the value is -1, not 1.
> Because an unlimited natural is supposed to be a natural number (i.e.,
> 0 or higher), the value of -1 is used as a special indicator to mean
> the maximum possible value. The same is done for upper bounds on Ecore
> features in EMF.