XNS Requirements

XNS currently has a long list of requirements before a number type is acceptable for usage in XNS.

  1. A single JavaScript function shall be defined as a constructor function, specifically to build the desired XNS number type in an object-oriented manner.
  2. The function must be able to accept at least three argument sets. The first argument set is of a single JavaScript number value, which will be mathematically equivalent in that XNS type's number system to the original argument. The second argument set is of a single XNS number identical in type to the XNS type being constructed, in which case the function must return an equal but entirely independent XNS number: none of the properties when changed in the original may affect the copy. The third argument set is of a single argment which is a valid XNS number type, for which the appropriate conversion function must be called.
  3. Any XNS number constructed must have the following properties and methods prototyped in, with appropriate arguments required:
  4. The XNS number type shall also provide a method of the Number function which directly references the constructor function. It must match the constructor function's name, prefixed by the characters "_to". For instance, Number._toBigDecimal() referencing the BigDecimal() constructor function.
  5. Any XNS number constructed (including those constructed through arithmetic operations) must be returned in the simplest types possible, unless there are practical reasons not to do so. This includes returning a different type of number for the same value. For instance, a Fraction() number where the numerator and the denominator are both equal to 3 should return as a BigDecimal() type or a Number() type equal to 1, instead of a Fraction type().
  6. The constructor function must be registered via the XNS_Types[] array with a numerical value. (Note: This is currently not implemented with any XNS number type.) The numerical value for Number() is reserved at 1. The next highest shall be for the number type which is next in line for conversions. This will be explained in detail in a future revision of this document. Any number wishing to be excluded from conversions must set its property name as the name for an XNS_Types[] array property, and the value for that property as false.
  7. The XNS number system must conform as closely as possible to the JavaScript1.5 implementation in Mozilla browsers. For instance, 1 / 0 in Mozilla is currently considered equal to +Infinity. Thusly, any XNS number equal to 1 divided by any XNS number equal to 0 must return +Infinity.
  8. The XNS number type must treat XNS numbers with the XNS types of "NaN", "Infinity", and "-Infinity" as equivalent to Number.NaN, +Infinity, and -Infinity, respectively. This requirement does not exclude the number type from treating JavaScript number values, which have an xnsType property of "Number", as NaN, +Infinity, and -Infinity, when those values are given.

Back to the XNS Main Page.

docs/Requirements.html version 1.0 created May 22, 2002