Something's out of round here
-
I found this code recently:
Public Sub Round100(ByRef amount As Long) If (Math.IEEERemainder(CDbl(amount), CDbl(100)) <> 0) Then amount = CLng(System.Math.Floor(amount / 100)) amount += 1 amount \*= 100 End If End Sub
-
Misleading name (it doesn't round) 1) Ought to be a function 2) Needless conversions (three of them) 3) Performs the divide twice 4) Should use Ceiling... or the
\
operator ( X| ) "Well, it's VB; of course it's a horror!", I here you say, but according to the comments it was ported from C++:void Round100(long &amount)
{
if (fmod((double)amount, (double)100) != 0)
{
amount/=100;
amount++;
amount*=100;
}
}
:doh:
-
-
I found this code recently:
Public Sub Round100(ByRef amount As Long) If (Math.IEEERemainder(CDbl(amount), CDbl(100)) <> 0) Then amount = CLng(System.Math.Floor(amount / 100)) amount += 1 amount \*= 100 End If End Sub
-
Misleading name (it doesn't round) 1) Ought to be a function 2) Needless conversions (three of them) 3) Performs the divide twice 4) Should use Ceiling... or the
\
operator ( X| ) "Well, it's VB; of course it's a horror!", I here you say, but according to the comments it was ported from C++:void Round100(long &amount)
{
if (fmod((double)amount, (double)100) != 0)
{
amount/=100;
amount++;
amount*=100;
}
}
:doh:
-
-
I found this code recently:
Public Sub Round100(ByRef amount As Long) If (Math.IEEERemainder(CDbl(amount), CDbl(100)) <> 0) Then amount = CLng(System.Math.Floor(amount / 100)) amount += 1 amount \*= 100 End If End Sub
-
Misleading name (it doesn't round) 1) Ought to be a function 2) Needless conversions (three of them) 3) Performs the divide twice 4) Should use Ceiling... or the
\
operator ( X| ) "Well, it's VB; of course it's a horror!", I here you say, but according to the comments it was ported from C++:void Round100(long &amount)
{
if (fmod((double)amount, (double)100) != 0)
{
amount/=100;
amount++;
amount*=100;
}
}
:doh:
-