Interval package: Difference between revisions

2,041 bytes added ,  25 October 2014
Line 82: Line 82:


==== Specialized interval constructors ====
==== Specialized interval constructors ====
Above mentioned interval construction with decimal numbers or numeric data is straightforward. Beyond that, there are more ways to define intervals or interval boundaries.
* Hexadecimal-floating-constant form: Each interval boundary may be defined by a hexadecimal number (optionally containing a point) and an exponent field with an integral power of two as defined by the C99 standard ([http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf ISO/IEC9899, N1256, §6.4.4.2]). This can be used as a convenient way to define interval boundaries in double precision, because the hexadecimal form is much shorter than the decimal representation of many numbers.
* Rational literals: Each interval boundary may be defined as a fraction of two decimal numbers. This is especially useful if interval boundaries shall be tightest enclosures of fractions, that would be hard to write down as a decimal number.
* Uncertain form: The interval as a whole can be defined by a midpoint or upper/lower boundary and an integral number of [http://en.wikipedia.org/wiki/Unit_in_the_last_place “units in last place” (ULPs)] as an uncertainty. The format is <code>''m''?''ruE''</code>, where
** <code>''m ''</code> is a mantissa in decimal,
** <code>''r ''</code> is either empty (which means ½ ULP) or is a non-negative decimal integral ULP count or is the <code>?</code> character (for unbounded intervals),
** <code>''u ''</code> is either empty (symmetrical uncertainty of ''r'' ULPs in both directions) or is either <code>u</code> (up) or <code>d</code> (down),
** <code>''E ''</code> is either empty or an exponent field comprising the character <code>e</code> followed by a decimal integer exponent (base 10).
octave:13> infsup ("0x1.999999999999Ap-4")
ans ⊂ [.1, .10000000000000001]
octave:14> infsup ("1/3", "7/9")
ans ⊂ [.33333333333333331, .7777777777777778]
octave:15> infsup ("121.2?")
ans ⊂ [121.14999999999999, 121.25]
octave:16> infsup ("5?32e2")
ans = [-2700, +3700]
octave:17> infsup ("-42??u")
ans = [-42, +Inf]


=== Decorations ===
=== Decorations ===
240

edits