The PackFloat 구조
The PackFloat 구조
이 구조는 부동소수점 실수의 문자열 표현과 packed(코드) 표현 사이 변환 연산을 제공해요. packed 표현은 시스템이 네트워크 바이트 순서(빅엔디안)로 저장하는 것을 가정해요.
출처: 문서
본문
시놉시스 (Synopsis)
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
인터페이스 (Interface)
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
설명 (Description)
val bytesPerElem : int
pack과 unpack 함수들은 Float와 Double 양쪽에 대한 기본 변환을 제공해요. toReal은 실수로 변환하며, fromReal은 실수에서 변환해요.
isBigEndian
IsLittleEndian은 타겟 시스템이 little-endian이면 true, big-endian이면 false를 돌려줘요.
val toBytes : real -> Word8Vector.vector
val fromBytes : Word8Vector.vector -> real
이 함수들은 부동소수점 값을 Word8Vector.vector 값 안팎으로 넣고 빼는 패킹·언패킹을 해요. 인자 벡터의 길이가 bytesPerElem보다 작으면 fromBytes는 Subscript 예외를 발생시켜요. 그렇지 않으면 처음 bytesPerElem개 바이트를 사용해요.
subVec (seq, i)
subArr (seq, i)
이 함수들은 집합체 seq의 부분 시퀀스를 추출해 구조의 엔디안 방식에 따라 실수 값으로 변환해요. i가 0보다 작거나 Word8Array.length seq < bytesPerElem * (i + 1)이면 Subscript 예외를 발생시켜요.
seq[bytesPerElem*i..bytesPerElem*(i+1)-1]
update (arr, i, r)
구조의 엔디안 방식에 따라 r을 배열 arr의 bytesPerElemi번째부터 bytesPerElem(i+1)-1번째 바이트에 저장해요. i가 0보다 작거나 Word8Array.length arr < bytesPerElem * (i + 1)이면 Subscript 예외를 발생시켜요.
더 알아보기 (Learn more)
- [ Top | Parent | Contents | Index | Root ] Generated April 12
- 2004 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 © 2004 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).