Oxygen Basic

Programming => Bugs & Feature Requests => Topic started by: Mike Lobanovsky on September 22, 2014, 01:44:40 AM

Title: [SOLVED] FPU Division Bug?
Post by: Mike Lobanovsky 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()



:(
Title: Re: FPU Division Bug?
Post by: Charles Pegge 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

Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky on September 22, 2014, 05:31:29 AM
THNX, PERFECT! :(
Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky 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...)
Title: Re: FPU Division Bug?
Post by: Charles Pegge 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.

.
Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky 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. :(
Title: Re: FPU Division Bug?
Post by: Charles Pegge 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


Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky 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?)
Title: Re: FPU Division Bug?
Post by: Charles Pegge 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.
Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky 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!
Title: Re: FPU Division Bug?
Post by: Charles Pegge 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.
Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky 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.)
Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky 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? ;)
Title: Re: FPU Division Bug?
Post by: JRS on September 22, 2014, 01:03:59 PM
Following you and Charles in these threads is like watching batting practice for the new season.  ;)
Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky 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. :)
Title: Re: FPU Division Bug?
Post by: Charles Pegge on September 22, 2014, 01:30:15 PM

Yes, I think this is solved. Sorry you were diverted, Mike - too many changes in parallel !

I'm taking a few hours off now for some lucid dreaming practice :)
Title: Re: FPU Division Bug?
Post by: JRS on September 22, 2014, 01:30:30 PM
Couldn't agree more. In fact I have been telling Eros that same thing for years. He must be holding out for a miracle.  :o

Title: Re: FPU Division Bug?
Post by: Mike Lobanovsky on September 22, 2014, 01:39:46 PM
It's my pleasure to work with you, Charles. Have a good rest! :)