NAME

flt2fix - convert a value or values from floating-point to fixed-point

SYNOPSIS

val.flt2fix(typ)

DESCRIPTION

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.

RETURN VALUE

An integral value of the specified Type typ

ERRORS

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

EXAMPLE

    1.->flt2fix(Byte)
127

    1.h->flt2fix(Ushort)
65535

SEE ALSO

fix2flt