Commit 335a5236 authored by Rob Pike's avatar Rob Pike

add sys.float32bits, sys.float64bits

R=rsc
DELTA=21  (21 added, 0 deleted, 0 changed)
OCL=18709
CL=18718
parent ce151585
......@@ -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 Inf(int) float64; // return signed Inf
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,
keyalg int, valalg int,
......
......@@ -39,6 +39,8 @@ char *sysimport =
"export func sys.isNaN (? float64) (? bool)\n"
"export func sys.Inf (? int) (? 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.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"
......
......@@ -347,6 +347,23 @@ sys·NaN(float64 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 uint8** argv;
static int32 envc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment