Author Topic: [SOLVED] FPU Division Bug?  (Read 2785 times)

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
[SOLVED] FPU Division Bug?
« on: September 22, 2014, 01:44:40 AM »
Charles,

Please run this:

function test() as double
  return 1.0
end function

print 5.0 / test()


or this:

function test() as double
  return 1.0
end function

print 5.0 \ test()


or this:

function test() as long
  return 1
end function

print 5 / test()


or this:

function test() as long
  return 1
end function

print 5.0 / test()


or this:

function test() as long
  return 1
end function

print 5.0 \ test()



This works:

function test() as long
  return 1
end function

print 5 \ test()



:(
« Last Edit: September 22, 2014, 01:41:46 PM by Mike Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3584
    • Oxygen Basic
Re: FPU Division Bug?
« Reply #1 on: September 22, 2014, 03:04:51 AM »

Sorry Mike, bad commutation, affecting n/fun() and n-fun()

Fixed:
http://www.oxygenbasic.org/o2zips/Oxygen.zip


Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
Re: FPU Division Bug?
« Reply #2 on: September 22, 2014, 05:31:29 AM »
THNX, PERFECT! :(
« Last Edit: September 22, 2014, 10:49:30 AM by Mike Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
Re: FPU Division Bug?
« Reply #3 on: September 22, 2014, 10:56:51 AM »
Sorry Charles,

It ain't perfect. Please run this:

string curchar = "3"
double tot = 3

print tot * 10 + val(curchar)


It yields 3. :(

(Can somebody give me the old gxo2.exe + Oxygen.dll from a zip before September 20 for the time being? I deleted mine when I got the new ones. :-[ I'm losing days to kill bugs in OxyLISP which aren't really there...)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3584
    • Oxygen Basic
Re: FPU Division Bug?
« Reply #4 on: September 22, 2014, 11:09:24 AM »
Mike, here is the previous gxo2. But there should not be any difference unless you are compiling from the console.

Please try with the current Oxygen.dll

This bug does not appear to be related to the recent fixes.

.
« Last Edit: September 22, 2014, 11:28:07 AM by Charles Pegge »

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
Re: FPU Division Bug?
« Reply #5 on: September 22, 2014, 11:29:34 AM »
Nope, the test fails with this gxo2.exe too. Seems the bug comes from the Oxygen.dll download above. Perhaps fixing division and subtraction causes it.

I lost the ability to enter fractional numbers into OxyLISP. E.g. if I'm trying to enter 3.333, I get 0.003. The multiplication result above is lost and only the trailing val() is added to empty tot that loses its initial value as well. :(
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3584
    • Oxygen Basic
Re: FPU Division Bug?
« Reply #6 on: September 22, 2014, 11:57:56 AM »
Ah yes, it has exposed a bug in val relating to extended types, used as temp storage.

May take a while to fix

Simple workaround: define your own val:

function val (string s ) as double
return s
end function



Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
Re: FPU Division Bug?
« Reply #7 on: September 22, 2014, 12:27:17 PM »
OK Charles,

I'll try to do that and will report shortly. But the gxo2 that you sent me is not the old gxo2 I used to use. That one was some 49KB in size while this one is just under 42KB. Or is my memory slipping me?

P.S. Can I overload an Oxygen keyword function just like that? (I can do it in FBSL but what about O2?)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3584
    • Oxygen Basic
Re: FPU Division Bug?
« Reply #8 on: September 22, 2014, 12:27:37 PM »
Okay, I've squelched it! Closer scrtutiny of the extended type will be needed in the future. Maybe to drop it.  - not C compatible.

val should now be okay.

http://www.oxygenbasic.org/o2zips/Oxygen.zip

It was the original gxo2, (skipping a more recent build). Perhaps you could try the latest gxo2 again - it should work exactly the same, except for the -m console option.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
Re: FPU Division Bug?
« Reply #9 on: September 22, 2014, 12:32:06 PM »
Yeah, guess that came from PowerBASIC via thinBasic, didn't it? ;)

Going 32 bits again to test your fixes and report.

Thanks!
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3584
    • Oxygen Basic
Re: FPU Division Bug?
« Reply #10 on: September 22, 2014, 12:39:02 PM »

Yes, you can override most things in Oxygen, globally or with limited scope. even register names, as long as you don't try to do asm with them in the same scope.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
Re: FPU Division Bug?
« Reply #11 on: September 22, 2014, 12:44:21 PM »
(Under 32 bits)

Overloading is OK. Does it relate to functions only? I can't overload FBSL keywords like FROM/TO/WHILE/DO/etc., only intrinsic, 3rd-party dll, and user functions. Is it the same in O2?

(P.S. See my report from 64 bits -- you haven't seen it yet, I suppose.)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
Re: FPU Division Bug?
« Reply #12 on: September 22, 2014, 12:50:39 PM »
Hehe yes,

Now my floats are working as expected, at least for now. You won't believe it but I spent 6 hours trying to debug my gcd() and lcm() functions for OxyLISP all in vain before I realized something was generally wrong with floats... :D

Can I now mark this thread [SOLVED], do you think? ;)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

John

  • Hero Member
  • *****
  • Posts: 3001
Re: FPU Division Bug?
« Reply #13 on: September 22, 2014, 01:03:59 PM »
Following you and Charles in these threads is like watching batting practice for the new season.  ;)

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1770
Re: FPU Division Bug?
« Reply #14 on: September 22, 2014, 01:18:24 PM »
Hi John,

That's only natural. Debugging a mature language is impossible without big projects. Mandelbrot pictures don't help at this stage any more. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)