Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Oldest QB45 bug ever known
#1
This error reported in QB45 has been there forever:

Code: (Select All)
Rem oldest QB45 bug ever known.
x$ = "9"
x = Int(Val(x$))
Print x ' returns 8
x = Int(Val(x$) + .5)
Print x ' returns 9
Rem no bug here:
x = CSng(Val(x$))
Print x ' returns 9
x = CInt(Val(x$))
Print x ' returns 9
x = Int(Val("&H" + x$))
Print x ' returns 9
End
However QB64 does not duplicate this error.

Am I incorrect in assuming this bug has been squashed?

Erik.
Reply
#2
The reason why QB64pe is better !
Why not yes ?
Reply
#3
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
Reply
#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
#5
Computers are great for data driven events, hell one day we may even have an A.I. President... Just don't ask him (it) to do simple math.

Pete

 - Just because I live in base ten, doesn't make me non-binary.
Reply
#6
(07-02-2024, 05:39 PM)Pete Wrote: Computers are great for data driven events, hell one day we may even have an A.I. President... Just don't ask him (it) to do simple math.

Pete

 - Just because I live in base ten, doesn't make me non-binary.

Which is why I carry around a calculator. I have no other way to figure out 2 plus 2 Big Grin 

The last time I asked for the value of 2 plus 2 all I got was 3.999
Reply
#7
First documented computer bug:

   

Caught trying to do trig Smile
b = b + ...
Reply
#8
@bplus: Can you do integral calc on a shroud???
Reply
#9
I wrote a 'Hello World' program on 30-some punch cards in 1979. I kept them until I went into practice in 1985; that was the same year I purchased a shredder. Hey, does anyone think shredding Fortran cards is the earliest form of encryption?

Pete Big Grin
Reply
#10
(07-17-2024, 04:07 AM)eoredson Wrote: @bplus: Can you do integral calc on a shroud???

Are you looking for miracles?

I just noticed the first actual case when when arctangent was started.
b = b + ...
Reply




Users browsing this thread: 5 Guest(s)