Actually, (and I know I'm being pedantic), mathematically speaking, shouldn't rounding 4.5677543201 be 4.6 - or are you more interested in the length rather than the accuracy?
If length is the only factor, here's another way:
A#=4.5677543201
B# = VAL(Left$(Str$(A#),Len(Str$(Int(A#)))+2))
If accuracy is required you need a function. (LBFN's and my above alternative method both return 4.5 when rounding 4.57 so they are just working on length rather than proper rounding).
The following works OK, but there are probably much more efficient ways to do it.
Function Round(Value#,Places)
IntegerVal=Int(Value#): Rem Before the decimal point
M#=Value#-IntegerVal: Rem After the decimal point
MantissaVal$ = Str$(M#)
X$=Right$(MantissaVal$,Len(MantissaVal$)-2)
NewMantissa = VAL(Left$(X$,Places))
RoundDigit = Val(Mid$(MantissaVal$,Places+3))
If RoundDigit >= 5
Inc NewMantissa
Else
Dec NewMantissa
Endif
Result# = VAL(Str$(IntegerVal)+"."+Str$(NewMantissa))
EndFunction Result#
Call it with:
A#=4.5677543201
Print Round(A#,1)
The 1 parameter is the number of places required.
TDK_Man