? "weight is " weight
A = Str(weight)
? "A is " A
weight is 8.6
A is 8.599999
weight = 8.6Then both lines print "8.6" just fine
"Komag" wrote:
The values that were added up to make 8.6 are:
1, 2, 1, 0.1, 0.2, 0.2, 0.1, 1, 2, 1
So there is no fancy division or anything like that, should be exact and straightforward.
"RokuKC" wrote:
The reason that Str and ? show different results is they happen to use slightly different values for the display precision.
BrightScript Debugger> a=12345.9996
BrightScript Debugger> ?Int(a)
12346
BrightScript Debugger> a=12345.9995
BrightScript Debugger> ?Int(a)
12345
BrightScript Debugger>
"belltown" wrote:
You'd think that Int() would always round down
Returns an integer representation of the argument, using the largest whole number that is not greater than the argument
"squirreltown" wrote:
I'm guessing fix() will have this issue too, which gives me the opportunity to ask what is the difference between fix() and int()
Returns a truncated representation of the argument. All digits to the right of the decimal point are simply chopped off, so the resultant value is an integer. For non-negative X, FIX(X)=lNT(X). For negative values of X, FIX(X)=INT(X)+1. For example, FIX(2.2) returns 2, and FIX(-2.2) returns -2.
"squirreltown" wrote:
and why isn't there one that rounds up? I can't possibly be the first one who needed that.
Whatever nonsense caused int(12345.9996) to be rounded up needs to be resolved.