Hey guys,
I’m trying to write some Ruby classes that take strings that conform to
the cannonical representations of XML Schema built in data types
(http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes) and I’m
running into some problems I’m hoping that you guys can help me with.
First, I’m running into troubles with the Doubles. According to the W3C,
the “value space of double consists of the values m × 2^e, where m is an
integer whose absolute value is less than 2^53, and e is an integer
between -1075 and 970, inclusive.” Now, I suspect that its supposed to
say “m × 10^e” but that isn’t my problem. My problem is that I simply
can’t seem to get the smallest values to come out as anything other than
0. I’m sure its possible I’m just not sure where to start.
My second problem has to do with the way the W3 defines numbers in
general. In addition to numbers as we all understand, they’ve added INF,
-INF, NaN and -0. Each of these have very specific meanings, most
insteresting is that -0 < 0 and NaN > INF. Now I was thinking that I
would implement INFClass and NaNClass similar to TrueClass and
FalseClass. However, I have no idea how to handle -0.
I’m not too worried about doing math with these special values so
perhaps it will be enough to have NegativeZeroClass.
Any help would be very much appreciated.
Adam van den Hoven.