adesutherland / CMS-370-BREXX

VM/370 Port of BREXX
Other
7 stars 5 forks source link

Scientific format output sometimes is missing characters #47

Open adesutherland opened 4 years ago

adesutherland commented 4 years ago

Example program

/* */         
TRACE DEBUG   
SAY 12E7      
SAY 12E7+1    
SAY 12E7+0    

Output

Internal DEBUG starting...   

Stck:0¦¦24¦NEWCLAUSE         

Stck:0¦¦28¦PUSH¦"12E7"       

Stck:1¦¦40¦SAY¦"12E7"        
12E7                         

Stck:0¦¦44¦NEWCLAUSE         

Stck:0¦¦48¦PUSHTMP           

Stck:1¦¦52¦PUSH¦"12E7"       

Stck:2¦¦64¦PUSH¦"1"          

Stck:3¦¦76¦ADD¦"12E7","1"    

Stck:1¦¦84¦SAY¦"120000001"   
120000001                    

Stck:0¦¦88¦NEWCLAUSE            

Stck:0¦¦92¦PUSHTMP              

Stck:1¦¦96¦PUSH¦"12E7"          

Stck:2¦¦108¦PUSH¦"0"            

Stck:3¦¦120¦ADD¦"12E7","0"      

Stck:1¦¦128¦SAY¦"12"            
12                              

Stck:0¦¦132¦NEWCLAUSE           

Stck:0¦¦136¦IEXIT¦"<NULL>"      
Return Code = 0                 
Freeing... 0: "12"              
Ready; T=0.03/0.07 08:43:37     

Maybe an error in SAY but more likely in conversion from Number (real?) to string

adesutherland commented 4 years ago

Note that 1e7 + 0 works fine ...

mgrossmann commented 4 years ago

Hello,

we, the other BREXXers, have been experimenting at this point for a long time. In the end, we gave up the subject. To my knowledge, there are architectural precision problems with floating point numbers on 360/370.

See https://en.wikipedia.org/wiki/IBM_hexadecimal_floating_point#Precision_issues https://en.wikipedia.org/wiki/IBM_hexadecimal_floating_point#Precision_issues

Attached is the output of your test:

READY
rexx float
12E7
120000001.000000008 120000000.000000008

Regards, Mike

Am 07.11.2020 um 09:46 schrieb Adrian Sutherland notifications@github.com:

Note that 1e7 + 0 works fine ...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/47#issuecomment-723419501, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF7Q7OXFC33OHV3GC3KQLTSOUCO7ANCNFSM4TNQWFMA.

adesutherland commented 4 years ago

Thanks Mike

I am sure there are issues with floating / rounding - just not sure if this is the root cause here. I have not had a chance to look at it yet but will report back.

One thing - at least with GCCLIB / PDPCLIB double precision maths is supported (well I gather it is actually an IBM's standard - HEX floating point) - but the point is it should support 15 digits precision comfortably. So the REXX default DIGITS 9 should be all good ("should be"!) ...

I have tried to keep each built in function fix in its own commit - so porting to MVS will be doable

adesutherland commented 3 years ago

Fixed in F0036

Basically BREXX does maths by converting integers to doubles does the operation then converts back to integers if both operations are integers ({sigh} performance!!). Anyway the F0036's fix of detecting if a float is an integer fixed this also.