1
0
mirror of https://github.com/golang/go synced 2024-11-26 17:56:55 -07:00

add sys.float32bits, sys.float64bits

R=rsc
DELTA=21  (21 added, 0 deleted, 0 changed)
OCL=18709
CL=18718
This commit is contained in:
Rob Pike 2008-11-06 15:48:36 -08:00
parent ce15158502
commit 335a5236e7
3 changed files with 21 additions and 0 deletions

View File

@ -49,6 +49,8 @@ export func isInf(float64, int) bool; // test for infinity
export func isNaN(float64) bool; // test for not-a-number export func isNaN(float64) bool; // test for not-a-number
export func Inf(int) float64; // return signed Inf export func Inf(int) float64; // return signed Inf
export func NaN() float64; // return a NaN export func NaN() float64; // return a NaN
export func float32bits(float32) uint32; // raw bits
export func float64bits(float64) uint64; // raw bits
export func newmap(keysize int, valsize int, export func newmap(keysize int, valsize int,
keyalg int, valalg int, keyalg int, valalg int,

View File

@ -39,6 +39,8 @@ char *sysimport =
"export func sys.isNaN (? float64) (? bool)\n" "export func sys.isNaN (? float64) (? bool)\n"
"export func sys.Inf (? int) (? float64)\n" "export func sys.Inf (? int) (? float64)\n"
"export func sys.NaN () (? float64)\n" "export func sys.NaN () (? float64)\n"
"export func sys.float32bits (? float32) (? uint32)\n"
"export func sys.float64bits (? float64) (? uint64)\n"
"export func sys.newmap (keysize int, valsize int, keyalg int, valalg int, hint int) (hmap *map[any] any)\n" "export func sys.newmap (keysize int, valsize int, keyalg int, valalg int, hint int) (hmap *map[any] any)\n"
"export func sys.mapaccess1 (hmap *map[any] any, key any) (val any)\n" "export func sys.mapaccess1 (hmap *map[any] any, key any) (val any)\n"
"export func sys.mapaccess2 (hmap *map[any] any, key any) (val any, pres bool)\n" "export func sys.mapaccess2 (hmap *map[any] any, key any) (val any, pres bool)\n"

View File

@ -347,6 +347,23 @@ sys·NaN(float64 out)
FLUSH(&out); FLUSH(&out);
} }
// func float32bits(float32) uint32; // raw bits of float32
void
sys·float32bits(float32 din, uint32 iou)
{
iou = *(uint32*)&din;
FLUSH(&iou);
}
// func float64bits(float64) uint64; // raw bits of float64
void
sys·float64bits(float64 din, uint64 iou)
{
iou = *(uint64*)&din;
FLUSH(&iou);
}
static int32 argc; static int32 argc;
static uint8** argv; static uint8** argv;
static int32 envc; static int32 envc;