Howdy jack!
Interesting.
From time to time there are small variations in the float (show as hex) between various implementations (not just Pure to other, but other to other as well). It seems these make little difference to the end result, and floats are a best approximation anyway.
So, my guess is that to all intents and purposes PureBasic is as accurate as anything else. Is that your call as well?
Double inacurracy
I think you were right, jack. I messed around with some simple rounding functions got the behavior like I wanted. I'm guessing the F64 library was similar in several ways but just had a neater double to string function and such. Thanks for the info! It really helped me get my project at work moving again ^_^
Incidentally, if anyone cares, here is the quick and dirty solution I made for doing a few decimal things for doubles.
Code: Select all
Procedure.d RoundTwo(Value.d)
;
Define.s HoldValue
;
Define.l HoldLength
;
HoldValue = StrD(Value, 4)
;
HoldLength = Len(HoldValue)
;
If Val(Mid(HoldValue, HoldLength - 1, 1)) >= 5
;
ProcedureReturn ValD(Left(HoldValue, HoldLength - 2)) + 0.01
;
Else
;
ProcedureReturn ValD(Left(HoldValue, HoldLength - 2))
;
EndIf
;
EndProcedure
Procedure.s TruncateD(Value.d)
;
Define.s HoldValue : HoldValue = StrD(Value, 4)
;
Define.l HoldLength : HoldLength = Len(HoldValue)
;
If Val(Right(HoldValue, 4)) = 0 : ProcedureReturn Left(HoldValue, HoldLength - 5) : Else : ProcedureReturn Left(HoldValue, HoldLength - 2) : EndIf
;
EndProcedure
Procedure.s CommaDouble(Value.d)
;
Define.s HoldValue
;
Define.s HoldString
;
Define.l HasDecimal
;
Define.l *Position
;
Define.b iCount
;
HoldValue = TruncateD(Value)
;
HasDecimal = FindString(HoldValue, ".", 1)
;
*Position = @HoldValue + Len(HoldValue) - 1
;
While *Position > @HoldValue - 1
;
If (HasDecimal And *Position - @HoldValue < HasDecimal - 1) Or HasDecimal = #False
;
If iCount = 3 : HoldString = "," + HoldString : iCount = 0 : EndIf
;
iCount + 1
;
EndIf
;
HoldString = PeekS(*Position, 1) + HoldString
;
*Position - 1
;
Wend
;
ProcedureReturn HoldString
;
EndProcedure
