PACK_REAL
signature
signature PACK_REAL
(* OPTIONAL *)
structure PackRealBig
:> PACK_REAL (* OPTIONAL *)
where type real = Real.real
structure PackRealLittle
:> PACK_REAL (* OPTIONAL *)
where type real = Real.real
structure PackReal<N>Big
:> PACK_REAL (* OPTIONAL *)
where type real = Real{N}.real
structure PackReal<N>Little
:> PACK_REAL (* OPTIONAL *)
where type real = Real{N}.real
The PACK_REAL
signature specifies the interface for packing and unpacking floating-point numbers into Word8
vectors and arrays. This provides a mechanism for transmitting floating-point values over a network.
For each optional Real<N>
structure provided by an implementation, the implementation may also provide a pair of structures PackReal<N>Big
and PackReal<N>Little
. These structures share the real type defined in Real<N>
. The PackReal<N>Big
structures perform big-endian packing and unpacking, and the PackReal<N>Little
structures perform little-endian packing and unpacking.
In addition, an implementation may provide the structures PackRealBig
and PackRealLittle
, which are aliases for the PACK_REAL
structures related to the default Real
structure.
type real
val bytesPerElem : int
val isBigEndian : bool
val toBytes : real -> Word8Vector.vector
val fromBytes : Word8Vector.vector -> real
val subVec : Word8Vector.vector * int -> real
val subArr : Word8Array.array * int -> real
val update : Word8Array.array * int * real -> unit
val bytesPerElem : int
real
.
isBigEndian
true
if the structure implements a big-endian view of the data.
val toBytes : real -> Word8Vector.vector
val fromBytes : Word8Vector.vector -> real
Word8Vector.vector
values. The function fromBytes
raises the Subscript
exception if the argument vector does not have length at least bytesPerElem
; otherwise the first bytesPerElem
bytes are used.
subVec (seq, i)
subArr (seq, i)
seq[bytesPerElem*i..bytesPerElem*(i+1)-1]of the aggregate seq and convert it into a
real
value according to the endianness of the structure. They raise the Subscript
exception if i < 0 or if Word8Array.length
seq < bytesPerElem
* (i + 1).
update (arr, i, r)
bytesPerElem
*i
through bytesPerElem
*(i+1)-1
of the array arr, according to the structure's endianness. It raises the Subscript
exception if i < 0 or if Word8Array.length
arr < bytesPerElem
* (i + 1).
PACK_WORD
,REAL
Generated October 02, 2003
Last Modified May 28, 2000
Comments to John Reppy.
This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy.
Copyright © 2003 AT&T and Lucent Technologies. All rights reserved.
Permission is granted for internet users to make one paper copy for their
own personal use. Further hardcopy reproduction is strictly prohibited.
Permission to distribute the HTML document electronically on any medium
other than the internet must be requested from the copyright holders by
contacting the editors.
Printed versions of the SML Basis Manual are available from Cambridge
University Press.
To order, please visit
www.cup.org (North America) or
www.cup.cam.ac.uk (outside North America). |