34
// The value is rounded down to the nearest representable value.
35
// Negative values go to 0 and values above the maximum representable go to 255.
37
>
if value <= 0 {
38
return 0
39
}
40
42
>
bitLen := bits.Len64(uval)
43
>
44
>
// Find shift such that uval >> shift is in [12, 23].
45
>
// This extracts the significand for the normalized representation.
46
>
shift := max(bitLen-5, 0)
47
>
sig := int(uval >> uint(shift))
48
>
if sig >= 24 {
49
>
shift++
50
>
sig = int(uval >> uint(shift))
51
>
}
52
54
>
55
>
if e >= 1 {
57
>
b := e*12 + m
58
>
if b > 255 {
59
return 255
60
}
62
}
63