BRender Technical Reference Manual:4 Data Structures (Alphabetical Reference):br_scalar
Next|Prev|Up
The Integral Type
Arithmetic
Comparison
Conversion
Copy/Assign

br_scalar


The Integral Type

The br_scalar
332 type is the general numerical representation used by BRender. Under the fixed point library, br_scalar332 is a 32 bit fixed point number (sign + 15 bit integer + 16 bit fraction), and can represent numbers between approximately -32768 and +32768. Under the floating point library, br_scalar332 is a float, and can represent numbers between approximately -3.4e38 and +3.4e38.

Use br_scalar332 instead of int, float or double, in all numerical modelling aspects of an application program.

The typedef

(See scalar.h for precise declaration)

float br_scalar Floating point

br_fixed_ls br_scalar Fixed - Long Signed (15.16)

Arithmetic

No standard arithmetic operators are supported. The following macros should be used instead. All arguments and return values are of type br_scalar332 (except where otherwise stated).

Macros for Standard Operations

BR_ADD(a,b)
Return the equivalent of a + b .

BR_SUB(a,b)
Return the equivalent of a - b .

BR_CONST_MUL(a,x)
Return the equivalent of a * x (where x is a numeric constant).

BR_MUL(a,b)
Return the equivalent of a * b .

BR_SQR(a)
Return the equivalent of a * a .

BR_RCP(a)
Return the equivalent of 1.0 / a .

BR_CONST_DIV(a,x)
Return the equivalent of a / x (where x is a numeric constant).

BR_DIV(a,b)
Return the equivalent of a / b.

BR_DIVR(a,b)
Return the equivalent of a / b (rounding toward zero instead of negative infinity*1).

BR_MULDIV(a,b,c)
Return the equivalent of a * b / c .

Macros for Standard Functions

BR_ABS(a)
Return the equivalent of fabs( a ) .

BR_POW(a,b)
Return the equivalent of pow( a , b ) .

BR_SQRT(a)
Return the equivalent of sqrt( a ) .

Macros for Vector and Matrix Oriented Arithmetic

For Two Pairs of Operands

BR_SQR2(a,b)
Return the equivalent of a * a + b * b .

BR_LENGTH2(a,b)
Return the equivalent of sqrt( a * a + b * b ) .

BR_RLENGTH2(a,b)
Return the equivalent of ( 1.0 / sqrt( a * a + b * b )) .

BR_MAC2(a,b,c,d)
Return the equivalent of a * b + c * d .

BR_MAC2DIV(a,b,c,d,e)
Return the equivalent of ( a * b + c * d ) / e .

For Three Pairs of Operands

BR_SQR3(a,b,c)
Return the equivalent of a * a + b * b + c * c .

BR_LENGTH3(a,b,c)
Return the equivalent of sqrt( a * a + b * b + c * c ) .

BR_RLENGTH3(a,b,c)
Return the equivalent of ( 1.0 / sqrt( a * a + b * b + c * c )) .

BR_MAC3(a,b,c,d,e,f)
Return the equivalent of a * b + c * d + e * f .

BR_MAC3DIV(a,b,c,d,e,f,g)
Return the equivalent of ( a * b + c * d + e * f ) / g .

For Four Pairs of Operands

BR_SQR4(a,b,c,d)
Return the equivalent of a * a + b * b + c * c + d * d .

BR_LENGTH4(a,b,c,d)
Return the equivalent of sqrt( a * a + b * b + c * c + d * d ) .

BR_RLENGTH4(a,b,c,d)
Return the equivalent of ( 1.0 / sqrt( a * a + b * b + c * c + d * d )) .

BR_MAC4(a,b,c,d,e,f,g,h)
Return the equivalent of a * b + c * d + e * f + g * h .

BR_MAC4DIV(a,b,c,d,e,f,g,h,i)
Return the equivalent of ( a * b + c * d + e * f + g * h ) / i .

Comparison

Equality and comparison with zero are valid. Other standard comparison operators may be implemented by macros in future versions, but are currently valid.

Conversion

From Numeric Constants

BR_SCALAR(x)
Convert x from any numeric constant to scalar type. Also see BR_CONST_MUL() and BR_CONST_DIV().

BR_SCALAR_EPSILON
Smallest representable positive scalar value.

BR_SCALAR_MIN
Largest representable negative scalar value.

BR_SCALAR_MAX
Largest representable positive scalar value.

From Integral Types

br_scalar BrIntToScalar(int i)
Converts i from any integer type to scalar type.

br_scalar BrFloatToScalar(int i)
Converts i from float or double type to scalar type.

From Other BRender Types

br_scalar BrAngleToScalar(br_angle a)
Converts a from angle type to scalar type.

br_scalar BrFixedToScalar(br_fixed_ls f)
Converts f from fixed type to scalar type.

br_scalar BrFractionToScalar(br_fraction f)
Converts f from fraction type to scalar type.

br_scalar BrUFractionToScalar(br_ufraction u)
Converts u from unsigned fraction type to scalar type.

To Integral Types

int BrScalarToInt(br_scalar s)
Converts s from scalar type to int.

float BrScalarToFloat(br_scalar s)
Converts s from scalar type to float.

To Other BRender Types

br_angle BrScalarToAngle(br_scalar s)
Converts a from scalar type to angle type.

br_fixed_ls BrScalarToFixed(br_scalar s)
Converts s from scalar type to fixed type.

br_fraction BrScalarToFraction(br_scalar s)
Converts f from scalar type to fraction type.

br_ufraction BrScalarToUFraction(br_scalar s)
Converts u from scalar type to unsigned fraction type.

Copy/Assign

Only assign zero, or scalars. Use conversions in all other cases.


Generated with
CERN WebMaker