Comparison of APL dialects: Difference between revisions

Jump to navigation Jump to search
m
(Expand complex numbers section to numeric types generally)
Line 29: Line 29:
Traditionally, APL supports only one numeric type that is visible to the user, such as a floating-point number, or complex number whose components are floating-point. Other numeric types may be used by the implementation, but only for optimization: for example, [[APL\360]] uses packed 1-bit [[Boolean]] and 4-bit integer arrays that are automatically converted to float if an operation yields a value that doesn't fit in the type. [[ISO/IEC 13751:2001]] specifies that different representations of a number must be indistinguishable to a conforming program (which can call primitives but not implementation-specific system functions).
Traditionally, APL supports only one numeric type that is visible to the user, such as a floating-point number, or complex number whose components are floating-point. Other numeric types may be used by the implementation, but only for optimization: for example, [[APL\360]] uses packed 1-bit [[Boolean]] and 4-bit integer arrays that are automatically converted to float if an operation yields a value that doesn't fit in the type. [[ISO/IEC 13751:2001]] specifies that different representations of a number must be indistinguishable to a conforming program (which can call primitives but not implementation-specific system functions).


Most often the numeric type is a 64-bit float, for instance [[wikipedia:IBM_hexadecimal_floating_point|HFP]] in early [[IBM]] dialects and [[wikipedia:IEEE 745|IEEE 745]] in new dialects since the 1980s. [[Dyalog APL]] supports 128-bit [[decimal float]]s by setting <syntaxhighlight lang=apl inline>⎕FR</syntaxhighlight>. Modern dialects tend to support [[complex number]]s, with exceptions including [[dzaima/APL]], [[APLX]], and [[APL+Win]]. Dialects with complex numbers also extend [[Circular]] (<syntaxhighlight lang=apl inline>○</syntaxhighlight>) to left arguments designed for complex numbers.
Most often the numeric type is a 64-bit float, for instance [[wikipedia:IBM_hexadecimal_floating_point|HFP]] in early [[IBM]] dialects and [[wikipedia:IEEE 754|IEEE 754]] in new dialects since the 1980s. [[Dyalog APL]] supports 128-bit [[decimal float]]s by setting <syntaxhighlight lang=apl inline>⎕FR</syntaxhighlight>. Modern dialects tend to support [[complex number]]s, with exceptions including [[dzaima/APL]], [[APLX]], and [[APL+Win]]. Dialects with complex numbers also extend [[Circular]] (<syntaxhighlight lang=apl inline>○</syntaxhighlight>) to left arguments designed for complex numbers.


Some newer dialects provide additional types that are distinguishable from floats, often by greater precision. Extended-precision integers are one possibility: for example, [[dzaima/APL]] provides these if requested with a trailing <code>L</code> in a numeric literal or <syntaxhighlight lang=apl inline>⎕BIG</syntaxhighlight>, while [[Kap]] uses exact rational numbers by default. [[NARS2000]] supports numerous numeric types, and [[April]] provides access to the [[wikipedia:Common Lisp|Common Lisp]] numeric tower, which also includes many types. [[GNU APL]] doesn't support arbitrary precision, but uses 64-bit integers by default, much like [[J]] or [[K]].
Some newer dialects provide additional types that are distinguishable from floats, often by greater precision. Extended-precision integers are one possibility: for example, [[dzaima/APL]] provides these if requested with a trailing <code>L</code> in a numeric literal or <syntaxhighlight lang=apl inline>⎕BIG</syntaxhighlight>, while [[Kap]] uses exact rational numbers by default. [[NARS2000]] supports numerous numeric types, and [[April]] provides access to the [[wikipedia:Common Lisp|Common Lisp]] numeric tower, which also includes many types. [[GNU APL]] doesn't support arbitrary precision, but uses 64-bit integers by default, much like [[J]] or [[K]].

Navigation menu