Re: Floating-point formats and standards Aubrey Jaffer 06 Jan 2005 06:08 UTC

This approach combines rank, dimensions, and new floats.  I punted
rank-0 for now.  The trailing `b' or `d' is a great idea.  I would
like the trailing `b' to be optional, but it doubles the number of
prototype functions.

I removed mention of IEEE.  Whatever implementation of floating point
one has, use it!  The defaulting rules of SRFI-47 need to be
redesigned.

			      -=-=-=-=-

				Syntax

The syntax for arrays is a prefix according to the type and rank of
the array followed by the list-decomposition of an array.  The prefix
must be immediately followed by a delimiter.  Upper and lower case
forms of a letter are not distinguished in the prefix characters.

By list-decomposition is meant rank nestings of lists of the elements
where the most nested list has length equal to the last dimension of
the array and at top level has length equal to the first dimension of
the array.  Vectors may substitute for lists at any nesting depth.

Rank 1 heterogeneous arrays which are not subarrays write and display
as Scheme vectors.

The prefix syntax is:

  array-prefix :: rank `A' [ dimensions ] [ `:' type-specifier ] |
                       `A' dimensions [ `:' type-specifier ]

  dimensions :: dimension | dimensions `*' dimension

  dimension :: nonnegative-integer

  rank :: positive-integer

  type-specifier :: `flo' { `c' | `r' } flowidth `b' |
                    `fix' { `z' | `n' } fixwidth `b' |
                    `flo' `r' decwidth `d'

  flowdith :: `16' | `32' | `64' | `128'

  fixwdith :: `8' | `16' | `32' | `64'

  decwdith :: `32' | `64' | `128'

prototype                                                   type
procedure   exactness   element type			    specifier
=========   =========   ============			    =========
vector      any
A:floc128b  inexact     128.bit binary flonum complex       floc128b
A:floc64b   inexact     64.bit binary flonum complex        floc64b
A:floc32b   inexact     32.bit binary flonum complex        floc32b
A:floc16b   inexact     16.bit binary flonum complex        floc16b
A:flor128b  inexact     128.bit binary flonum real          flor128b
A:flor64b   inexact     64.bit binary flonum real           flor64b
A:flor32b   inexact     32.bit binary flonum real           flor32b
A:flor16b   inexact     16.bit binary flonum real           flor16b
A:flor128d  exact       128.bit decimal flonum real         flor128d
A:flor64d   exact       64.bit decimal flonum real          flor64d
A:flor32d   exact       32.bit decimal flonum real          flor32d
A:fixz64    exact       64.bit binary fixnum                fixz64b
A:fixz32    exact       32.bit binary fixnum                fixz32b
A:fixz16    exact       16.bit binary fixnum                fixz16b
A:fixz8     exact       8.bit binary fixnum                 fixz8b
A:fixn64    exact       64.bit nonnegative binary fixnum    fixn64b
A:fixn32    exact       32.bit nonnegative binary fixnum    fixn32b
A:fixn16    exact       16.bit nonnegative binary fixnum    fixn16b
A:fixn8     exact       8.bit nonnegative binary fixnum     fixn8b
A:bool                  boolean                             bool

A two-by-three array of nonnegative 16.bit integers is written:

#2A:fixn16b((0 1 2) (3 5 4))

Note that this is the external representation of an array, not an
expression evaluating to a array.  Like vector constants, array
constants must be quoted:

'#2a:FIXN16b((0 1 2) (3 5 4))
               ==> #2A:fixn16b((0 1 2) (3 5 4))

			      Semantics

(array-dimensions '#2A:fixn16b((0 1 2) (3 5 4))) ==> (2 3)

An equivalent array could have been created by

(define ra (make-array (A:fixn16b) 2 3))
(array-set! ra 0 0 0)
(array-set! ra 1 0 1)
(array-set! ra 2 0 2)
(array-set! ra 3 1 0)
(array-set! ra 5 1 1)
(array-set! ra 4 1 2)

Literal array constants are immutable objects.  It is an error to
attempt to store a new value into a location that is denoted by an
immutable object.

The following equivalences will be defined to alias SRFI-47 names to
the new ones.  SRFI-47 should be replaced to make these be the
array-prototype-procedures:

(define A:floc128b ac64)
(define A:floc64b ac64)
(define A:floc32b ac32)
(define A:floc16b ac32)
(define A:flor128b ar64)
(define A:flor64b ar64)
(define A:flor32b ar32)
(define A:flor16b ar32)

(define A:flor128d ac64)
(define A:flor64d ac64)
(define A:flor32d ac32)

(define A:fixz64b as64)
(define A:fixz32b as32)
(define A:fixz16b as16)
(define A:fixz8b  as8)
(define A:fixn64b au64)
(define A:fixn32b au32)
(define A:fixn16b au16)
(define A:fixn8b  au8)
(define A:bool    at1)