Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
Functions
The floatting point number API.

Functions

 std_fClamp (f, startf, endf)
 Clamp a float number in a range. More...
 
 std_fCmp (f1, f2)
 Compare two float numbers (depending of epsilon) More...
 
 std_fDivide (f1, f2)
 Perform a division between two float numbers The function returns a tuple : the result, the entire and the decimal parts of the result. More...
 
 std_fEpsilonGet ()
 Get the 'epsilon' to compare deux floating point numbers. More...
 
 std_fEpsilonSet (f)
 Set the 'epsilon' to compare deux floating point numbers. More...
 
 std_fInRange (f, startf, endf)
 Return if a a float number in a range. More...
 
 std_fIntDec (f)
 Return the entire and the decimal parts of a float number. More...
 
 std_fIsZero (f)
 Return if a float number is near at zero (depending of epsilon) More...
 
 std_vectorIsEqualF (v1, v2)
 Return if two float vectors are equals. More...
 

Detailed Description

Package to load : lib/std/float.pkg

Function Documentation

std_fEpsilonGet ( )

Get the 'epsilon' to compare deux floating point numbers.

By default, this value is 0.000001

Prototype : : fun [] F

Returns
F : the current epsilon
std_fEpsilonSet ( )

Set the 'epsilon' to compare deux floating point numbers.

By default, this value is 0.000001

Prototype : : fun [F] F

Parameters
F: a new 'epsilon'
Returns
F : the same value
std_fIsZero ( )

Return if a float number is near at zero (depending of epsilon)

See also
std_fEpsilonSet
std_fEpsilonGet

Prototype : : fun [F] I

Parameters
F: value to test
Returns
I : 1 if zero else 0
std_fCmp ( f1  ,
f2   
)

Compare two float numbers (depending of epsilon)

See also
std_fEpsilonSet
std_fEpsilonGet

Prototype : : fun [F F] I

Parameters
F: a float number
F: another float number
Returns
I : 1 if they are equals else 0
std_fInRange ( ,
startf  ,
endf   
)

Return if a a float number in a range.

Prototype : : fun [F F F] I

Parameters
F: a float number
F: the bottom of the range (start)
F: the top of the range (end)
Returns
I : 1 if success, 0 if fail or nil if error (start > end)
std_fClamp ( ,
startf  ,
endf   
)

Clamp a float number in a range.

Prototype : : fun [F F F] F

Parameters
F: a float number
F: the bottom of the range (start)
F: the top of the range (end)
Returns
F : the float number clamped or nil if error (start > end)
std_fIntDec ( )

Return the entire and the decimal parts of a float number.

Remarks
the decimal part can be rounded.

Prototype : : fun [F] [I F]

Parameters
F: a float number
Returns
[I F] : the tuple
std_fDivide ( f1  ,
f2   
)

Perform a division between two float numbers The function returns a tuple : the result, the entire and the decimal parts of the result.

_fooS sprintf "%f %i %f" std_fDivide 10.25 5.0; // 2,050000 2 0,050000
Remarks
the decimal part can be rounded.

Prototype : : fun [F] [F I F]

Parameters
F: a float number
Returns
[F I F] : the result and the entire and decimal parts of the result
std_vectorIsEqualF ( v1  ,
v2   
)

Return if two float vectors are equals.

Prototype: fun [[F F F] [F F F]] I

Parameters
[FF F] : first float vector
[FF F] : second float vector
Returns
I : 1 if are equuals else 0
Remarks
The float number are compared with an 'epsilon'.