Hey Jim,
Whilst we are at it,
in coming to need a ceiling/rounding type function,
and refreshing up on the fpround function,
they all lack the ability to round up/down to a specific range.
Excels Ceiling, floor function caters for this nicely and has spoiled us excel
mavericks.
I have located the algorithm online.
Might it be worthwhile to update the native ceil/floor HB functions to the more
advanced functionality?
Any other users think this might be a nice positive?
The code is below.
'RangedCeilingFloorFunction.bas
'-------------------------------
showconsole
Declare Function Ceiling(ceilingArg As Double, ceilingFactor As Double) As
Double
Function Ceiling(ceilingArg As Double, ceilingFactor As Double) As Double
' ceilingArg is the value you want to round
' ceilingFactor is the multiple to which you want to round
Ceiling = (Int(ceilingArg / ceilingFactor) + (IIF(ceilingArg MOD
ceilingFactor <> 0,1,0))) * ceilingFactor
End Function
Declare Function Floor(floorArg As Double, floorFactor As Double) As Double
Function Floor(floorArg As Double, floorFactor As Double) As Double
' floorArg is the value you want to round
' floorFactor is the multiple to which you want to round
Floor = Int(floorArg / floorFactor) * floorFactor
End Function
print Floor(110.2,10) ' Floor to nearest 10
print Ceiling(13,6) ' Ceiling to Nearest 6
pause
'-------------------------------
credit to: ' http://www.pcreview.co.uk/forums/thread-1692063.php
.enpsuedo