ctio (3) - Linux Manuals
ctio: integer and float operations
NAME
ctio, ruint8, ruint16, ruint32, ruint64, wuint8, wuint16, wuint32, wuint64, rsint8, rsint16, rsint32, rsint64, wsint8, wsint16, wsint32, wsint64, rfloat, rdouble, wfloat, wdouble - integer and float operationsSYNOPSIS
var mod_ctype = require('ctype'); Number mod_ctype.ruint8(Buffer buf, String endian, Number offset);
Number mod_ctype.ruint16(Buffer buf, String endian, Number offset);
Number mod_ctype.ruint32(Buffer buf, String endian, Number offset);
Number[2] mod_ctype.ruint64(Buffer buf, String endian, Number offset);
Number mod_ctype.rsint8(Buffer buf, String endian, Number offset);
Number mod_ctype.rsint16(Buffer buf, String endian, Number offset);
Number mod_ctype.rsint32(Buffer buf, String endian, Number offset);
Number[2] mod_ctype.rsint64(Buffer buf, String endian, Number offset);
Number mod_ctype.rfloat(Buffer buf, String endian, Number offset);
Number mod_ctype.rdouble(Buffer buf, String endian, Number offset);
void mod_ctype.wuint8(Number value, String endian, Buffer buf, Number offset);
void mod_ctype.wuint16(Number value, String endian, Buffer buf, Number offset);
void mod_ctype.wuint32(Number value, String endian, Buffer buf, Number offset);
void mod_ctype.wuint64(Number[2] value, String endian, Buffer buf, Number offset);
void mod_ctype.wsint8(Number value, String endian, Buffer buf, Number offset);
void mod_ctype.wsint16(Number value, String endian, Buffer buf, Number offset);
void mod_ctype.wsint32(Number value, String endian, Buffer buf, Number offset);
void mod_ctype.wsint64(Number[2] value, String endian, Buffer buf, Number offset);
void mod_ctype.wfloat(Number value, String endian, Buffer buf, Number offset);
void mod_ctype.wdouble(Number value, String endian, Buffer buf, Number offset);
DESCRIPTION
The argument buf refers to a valid buffer (from calling new Buffer()). The argument endian is either the string 'big' or 'little' and controls whether the data in the buffer is interpreted as big or little endian. The argument offset indicates the starting index into the buffer to read or write. All functions ensure that starting at offset does not overflow the end of the buffer. The argument value is a Number that is the valid type for the specific function. All functions that take value as an argument, verify that the passed value is valid.
ruint8(), ruint16(), ruint32()
The ruint8(), ruint16(), and ruint32() functions read an 8, 16, and 32-bit unsigned value from buf and return it. The value read is influenced by the values of offset and endian.
rsint8(), rsint16(), rsint32()
The ruint8(), ruint16(), and ruint32() functions work just as ruint8(), ruint16(), and ruint32(), except they return signed integers.
ruint64(), rsint64()
The ruint64() and rsint64() functions read unsigned and signed 64 bit integers respectively from buf. Due to the limitations of ECMAScript's Number type, they cannot be stored as one value without a loss of precision. Instead of returning the values as a single Number, the functions return an array of two numbers. The first entry always contains the upper 32-bits and the second value contains the lower 32-bits. The lossy transformation into a number would be res[0]*Math.pow(2,32)+res[1]. Note that, unless an entry is zero, both array entries are guaranteed to have the same sign.
wuint8(), wuint16(), wuint32()
The functions wuint8(), wuint16(), and wuint32() modify the contents of buf by writing an 8, 16, and 32-bit unsigned integer respectively to buf. It is illegal to pass a number that is not an integer within the domain of the integer size, for example, for wuint8() the valid range is [0, 255]. The value will be written in either big or little endian format based upon the value of endian.
wsint8(), wsint16(), wsint32()
The functions wsint8(), wsint16(), and wsint32() function identically to the functions wuint8(), wuint16(), and wuint32() except that they the valid domain for value is that of a signed number instead of an unsigned number. For example the wsint8() has a domain of [-128, 127].
wuint64(), wsint64()
The functions wuint64() and swint64() write out 64-bit unsigned and signed integers to buf. The value argument must be in the same format as described in ruint64() and rsint64().
rfloat(), rdouble()
The functions "rfloat() and rdouble()" work like the other read functions, except that they read a single precision and double precision IEEE-754 floating point value instead.
wfloat(), wdouble()
The functions "rfloat() and rdouble()" work like the other write functions, except that the domain for a float is that of a single precision 4 byte value. The domain for a double is any Number in ECMAScript, which is defined to be represented by a double.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
|
All functions are MT-safe in so far as there aren't shared memory MT concerns in most node programs. If one where to concoct such an environment, these functions wouldn't be MT-safe.
SEE ALSO