Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Oldest QB45 bug ever known
#4
(07-02-2024, 07:19 AM)SMcNeill Wrote: I'd never swear to this type of glitch being fully squashed.   VAL returns a floating point value to us.  Not all floating point values work out to be exactly what we'd think they might be.   x = VAL("10") may somehow magically return a value of 9.9999999999999999 due to the way floating point numbers work.   QB4PE tries to avoid this issue, as much as possible, but it's an underlying component of just the way floating point works.

Any time you work with floating point values, I'd never swear that you'd get exact integers.  If you want integers, then assign it to an integer variable.  Chances are, if the value ends up being 9.99999999999 or 1.0000000000001e12, or whatever, it'll end up rounding to the proper value for you naturally.

Code: (Select All)
x$ = "9"
x& = Val(x$)
x = x&
Print x
End
Alright. That's what I thought was happening. I am working on a project called Strek (which you can find in the Games forum).

I was trying to convert a string array to Integer and it returned values of less than 1 for conversion.

Thought it was an error in my code but apparently not.

Erik.
Reply


Messages In This Thread
Oldest QB45 bug ever known - by eoredson - 07-02-2024, 06:53 AM
RE: Oldest QB45 bug ever known - by euklides - 07-02-2024, 07:07 AM
RE: Oldest QB45 bug ever known - by SMcNeill - 07-02-2024, 07:19 AM
RE: Oldest QB45 bug ever known - by eoredson - 07-02-2024, 07:41 AM
RE: Oldest QB45 bug ever known - by Pete - 07-02-2024, 05:39 PM
RE: Oldest QB45 bug ever known - by eoredson - 07-15-2024, 02:22 AM
RE: Oldest QB45 bug ever known - by bplus - 07-15-2024, 01:08 PM
RE: Oldest QB45 bug ever known - by eoredson - 07-17-2024, 04:07 AM
RE: Oldest QB45 bug ever known - by bplus - 07-17-2024, 08:23 AM
RE: Oldest QB45 bug ever known - by Pete - 07-17-2024, 08:13 AM
RE: Oldest QB45 bug ever known - by bplus - 07-17-2024, 08:34 AM
RE: Oldest QB45 bug ever known - by Pete - 07-17-2024, 02:52 PM
RE: Oldest QB45 bug ever known - by eoredson - 07-31-2024, 02:01 AM
RE: Oldest QB45 bug ever known - by eoredson - 07-31-2024, 03:07 AM



Users browsing this thread: 3 Guest(s)