Bug #79
closed
Val function only converts integer portion of string.
Added by Anonymous almost 5 years ago.
Updated about 4 years ago.
Description
Example: (all return integers)
X$="1234.56"
Y$="-234.56"
Print Val(X$), Val(Y$) ' Should print: 1234.56 -234.56
Vx=Val(X$):Vx#=Val(X$)
Print Vx,Vx# ' Should print 1234 1234.56
Vy=Val(Y$):Vy#=Val(Y$)
Print Vy,Vy# ' Should print -234 -234.56
Files
Oops! Forgot to login again: Brian Flanagan
- Description updated (diff)
- Assignee set to Francois Lionet
1234 -234
1234 1234
-234 -234
1234.56 -234
1234 1234.56
-234 -234.56
- Status changed from Resolved to Feedback
Tested in 0.9.5.1 Partially working.
The third example works wrong with integers.
It is rounding instead of taking the integer portion.
It should return -234 vs. -235
- Affected version changed from 0.9.3.1 to 0.9.8.1
re-tested in 0.9.8.1 Example 3 still fails.
First value should be an integer, but was rounded up.
Example 3:
X$="1234.56"
Y$="-234.56"
Vy=Val(Y$):Vy#=Val(Y$)
Print Vy,Vy# ' Should print -234 -234.56
Result should be:
-234 -234.56
Instead, I get:
-235 -234.56
- Status changed from Feedback to In Progress
- Assignee changed from Francois Lionet to Brian Flanagan
I know what needs to change for the one remaining function that is failing.
Vy=Val(Y$) is being converted to an integer using floor(). That's Ok for positive numbers only.
Negative numbers should use ceil() instead.
- Status changed from In Progress to Resolved
Fixed the last part of this that wasn't working.
Corrected this same issue in several places in the code.
- Status changed from Resolved to Closed
Also available in: Atom
PDF