wrong results with abs() in Alpha 1-3

All bugs related to new C backend
Realizimo
User
User
Posts: 51
Joined: Sun Nov 25, 2012 5:27 pm
Location: Sweden

wrong results with abs() in Alpha 1-3

Post by Realizimo »

Code: Select all

a=Abs(-4.5)
Debug a
; asm: a=4
; C: a=5
User avatar
STARGÅTE
Addict
Addict
Posts: 1565
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: wrong results with abs() in Alpha 1-3

Post by STARGÅTE »

This behavior was announced by Fred:
Fred wrote: Wed May 19, 2021 10:08 am C Backend limitations:
  • No Label address in datasection (?Label)
  • No Label operation in 'Debug' output window
  • No DLL creation support (in progress)
  • Empty Structure are not supported (may be add a compiler error on PB side ?)
  • Float to long rounding are not exactly the same (use bankerrounding)
But I wondering, because it looks like ASM is banker rounding and C is traditional.

Code: Select all

Define Integer.i
Define Float.f

For I = -5 To 4
	
	Float = I + 0.5
	Integer = Float
	Debug StrF(Float) + " --> " + Str(Integer)
	
Next
ASM: (round to even)
-4.5 --> -4
-3.5 --> -4
-2.5 --> -2
-1.5 --> -2
-0.5 --> 0
0.5 --> 0
1.5 --> 2
2.5 --> 2
3.5 --> 4
4.5 --> 4
C: (round to infinity)
-4.5 --> -5
-3.5 --> -4
-2.5 --> -3
-1.5 --> -2
-0.5 --> -1
0.5 --> 1
1.5 --> 2
2.5 --> 3
3.5 --> 4
4.5 --> 5
PB 5.73 ― Win 10, 20H2 ― Ryzen 9 3900X ― Radeon RX 5600 XT ITX ― Vivaldi 4.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Realizimo
User
User
Posts: 51
Joined: Sun Nov 25, 2012 5:27 pm
Location: Sweden

Re: wrong results with abs() in Alpha 1-3

Post by Realizimo »

thanks, I made a change in a chess program and now I get the same result
Post Reply