flt2fix - convert a value or values from floating-point to fixed-point
val.flt2fix(typ)
val must be a Half,
Float, Double, or an array of
those types
typ - one of Byte,
Ubyte, Short, or
Ushort
flt2fix converts a value or array of values
from floating point to a specified 8- or 16-bit signed or unsigned
fixed-point integer. The floating point number or array val is
clamped to the range -1. to -1. inclusive (for signed types) or 0. to
1. inclusive (for unsigned types), multiplied by a conversion factor,
then rounded to the nearest integer and stored as the requested
typ. The typ is one of Byte,
Ubyte, Short, or
Ushort. The conversion factors are:
| typ | Multiplier |
|---|---|
Byte |
127. |
Ubyte |
255. |
Short |
32767. |
Ushort |
65535. |
An integral value of the specified Type
typ
TypeCheck is thrown if typ is not a
Type
RangeCheck is
thrown if typ is not one of the short integral types
TypeCheck is thrown if val does not have a
floating point type
1.->flt2fix(Byte)
127
1.h->flt2fix(Ushort)
65535