03-22-2005, 04:42 AM
Jean,
Are you going to impliment more elementary functions in the library?
For example the floor, ceiling, and round? What follows are limited versions that aren't well tested but should give an idea.
Also, would you be open to expanding the constants list?
Are you going to impliment more elementary functions in the library?
For example the floor, ceiling, and round? What follows are limited versions that aren't well tested but should give an idea.
Code:
Function Round (x as double, Digit_Count as integer = 0) as double
dim MaxRoundPlaces as integer
MaxRoundPlaces = 16
dim ReturnAnswer as double
ReturnAnswer = 0
If (Digit_Count >= 0) and (Digit_Count < MaxRoundPlaces) then
Dim Dec_Place as double
Dec_Place = 10 ^ Digit_Count
ReturnAnswer = int((abs (x) * Dec_Place) + 0.5)
ReturnAnswer = Sgn(x) * ReturnAnswer / Dec_Place
else
'raise an error
end if
Round = ReturnAnswer
End Function
Function Ceil (x as double) as integer
Dim ReturnAnswer as integer
ReturnAnswer = int(x)
if ReturnAnswer < x then ReturnAnswer = ReturnAnswer + 1
Ceil = ReturnAnswer
End Function
Function Floor (x as Double) as integer
Dim ReturnAnswer as integer
ReturnAnswer = int(x)
if ReturnAnswer > x then ReturnAnswer = ReturnAnswer - 1
Floor = ReturnAnswer
End Function
Also, would you be open to expanding the constants list?