W
WWKougar
Hi all
Wonder if I could have a point in the right direction with the
creation of this function I call RoundHalf
Option Compare Database
Option Explicit
'X is either a temperature or gravity Value
Dim X As Single
Function RoundHalf(X)
TX = Int(X)
Diff = X - TX
If Diff >= 0 Then SIGN = 1.0
Else: SIGN = -1.0
Diff = Abs(Diff)
If Diff < 0.25 Then X = TX
If Diff >= 0.75 Then X = TX + 1.0 * SIGN
Else: X = TX + 0.5 * SIGN
End Function
I would like the function to round a temperature or a density calculation
to the nearest .5 of a degree. If the value is less than or equal to .25 of
a degree, it rounds down. If it is Greater than or equal to .75 of a degree
it rounds up. Anything else, it rounds to .5
Thanks in advance
wwkougar
Wonder if I could have a point in the right direction with the
creation of this function I call RoundHalf
Option Compare Database
Option Explicit
'X is either a temperature or gravity Value
Dim X As Single
Function RoundHalf(X)
TX = Int(X)
Diff = X - TX
If Diff >= 0 Then SIGN = 1.0
Else: SIGN = -1.0
Diff = Abs(Diff)
If Diff < 0.25 Then X = TX
If Diff >= 0.75 Then X = TX + 1.0 * SIGN
Else: X = TX + 0.5 * SIGN
End Function
I would like the function to round a temperature or a density calculation
to the nearest .5 of a degree. If the value is less than or equal to .25 of
a degree, it rounds down. If it is Greater than or equal to .75 of a degree
it rounds up. Anything else, it rounds to .5
Thanks in advance
wwkougar