Home » Modeling » UML2 » LiteralUnlimitedNatural why int(why is LiteralUnlimitedNatural a int and not a long)

Re: LiteralUnlimitedNatural why int [message #1322317 is a reply to message #1322265] 
Tue, 29 April 2014 20:08 
Christian W. Damus Messages: 1104 Registered: July 2009 
Senior Member 


Hi, Pieter,
The only meaningful differences between UML's UnlimitedNatural and
Integer types are:
* UnlimitedNatural's range does not include zero and negative numbers
(like the
natural numbers of mathematics)
* UnlimitedNatural includes the special ' * ' value indicating an
unlimited upper multiplicity
bound (which does not correspond to any number in the mathematical
natural domain)
As UnlimitedNatural has no negative space, it is convenient to
represent ' * ' with 1 in Java.
Apart from that, long hasn't sufficient precision to represent the
entire natural domain, and BigInteger is unwieldy for such common usage
as multiplicity, so int is the most practical Javaish representation.
Note that, in practice, it is probably quite rare to see any other
multiplicity upper bounds than 1, 2, or * .
HTH,
Christian
On 20140429 19:30:53 +0000, Pieter Martin said:
> Hi,
>
> I just recently realized that a LiteralUnlimitedNatural is a int. I
> expected it to be a long.
>
> Is there a reason why it is not a java long?
>
> Thanks
> Pieter


 
Re: LiteralUnlimitedNatural why int [message #1322355 is a reply to message #1322317] 
Tue, 29 April 2014 20:31 
Ed Willink Messages: 4846 Registered: July 2009 
Senior Member 


Hi
Correction: An UnlimitedNatural may have the value zero.
[In EMF, the value 2 is also used for some undecided XSD status.]
However since UnlimitedNatural is only used to describe the upper bound
of a multiplicity, a zero value can never be used in a useful model.
Note that UnlimitedNatural is not a number, despite my misguided
rationalization in OCL 2.3 that will hopefully be reverted in OCL 2.5.
UnlimitedNatural has a value '*' that is unrepresentable as either
Integer or Real, therefore UnlimitedNatural does not conform to Integer
or Real and should not be freely convertible to Integer or Real. Expect
UnlimitedNatral to become increasingly unusable without explicit
conversions.
You are better off thinking of UnlimitedNatural as an Enumeration with a
very large number of enumerated values.
Integer and UnlimitedNatural are unbounded so neither int nor long is
adequate. Some tools impose limitations that work nearly always but the
occasional consumer complains. Eclipse OCL has grown from int to long;
the Pivot OCL uses Number and so supports the most convenient
polymorphic representation.
Regards
Ed Willink
On 29/04/2014 21:08, Christian W. Damus wrote:
> Hi, Pieter,
>
> The only meaningful differences between UML's UnlimitedNatural and
> Integer types are:
>
> * UnlimitedNatural's range does not include zero and negative numbers
> (like the
> natural numbers of mathematics)
> * UnlimitedNatural includes the special ' * ' value indicating an
> unlimited upper multiplicity
> bound (which does not correspond to any number in the mathematical
> natural domain)
>
> As UnlimitedNatural has no negative space, it is convenient to
> represent ' * ' with 1 in Java.
>
> Apart from that, long hasn't sufficient precision to represent the
> entire natural domain, and BigInteger is unwieldy for such common
> usage as multiplicity, so int is the most practical Javaish
> representation.
>
> Note that, in practice, it is probably quite rare to see any other
> multiplicity upper bounds than 1, 2, or * .
>
> HTH,
>
> Christian
>
>
> On 20140429 19:30:53 +0000, Pieter Martin said:
>
>> Hi,
>>
>> I just recently realized that a LiteralUnlimitedNatural is a int. I
>> expected it to be a long.
>>
>> Is there a reason why it is not a java long?
>>
>> Thanks
>> Pieter
>
>


   
Goto Forum:
Current Time: Sat Jul 23 09:44:06 GMT 2016
Powered by FUDForum. Page generated in 0.04281 seconds
