
PureBasic 4.20 Beta 4 (Windows)
wrong float
hi,
today i use float in new version and result is weird
today i use float in new version and result is weird
Code: Select all
For c = 1 To 10
Debug 0.1 * c
Debug 1 + ( 0.1 * c )
Debug 2 + ( 0.1 * c )
Debug 3 + ( 0.1 * c )
Debug 4 + ( 0.1 * c )
Debug 5 + ( 0.1 * c )
Debug 6 + ( 0.1 * c )
Debug 7 + ( 0.1 * c )
Debug 8 + ( 0.1 * c )
Debug 9 + ( 0.1 * c )
Debug ""
Next
Code: Select all
RESULT:
0.10000000000000001
1.10000002384186
2.09999990463257
3.09999990463257
4.09999990463257
5.09999990463257
6.09999990463257
7.09999990463257
8.10000038146973
9.10000038146973
0.20000000000000001
1.20000004768372
2.20000004768372
3.20000004768372
4.19999980926514
5.19999980926514
6.19999980926514
7.19999980926514
8.19999980926514
9.19999980926514
0.30000000000000004
1.29999995231628
2.29999995231628
3.29999995231628
4.30000019073486
5.30000019073486
6.30000019073486
7.30000019073486
8.30000019073486
9.30000019073486
0.40000000000000002
1.39999997615814
2.40000009536743
3.40000009536743
4.40000009536743
5.40000009536743
6.40000009536743
7.40000009536743
8.39999961853027
9.39999961853027
0.5
1.5
2.5
3.5
4.5
5.5
6.5
7.5
8.5
9.5
0.60000000000000009
1.60000002384186
2.59999990463257
3.59999990463257
4.59999990463257
5.59999990463257
6.59999990463257
7.59999990463257
8.60000038146973
9.60000038146973
0.70000000000000007
1.70000004768372
2.70000004768372
3.70000004768372
4.69999980926514
5.69999980926514
6.69999980926514
7.69999980926514
8.69999980926514
9.69999980926514
0.80000000000000004
1.79999995231628
2.79999995231628
3.79999995231628
4.80000019073486
5.80000019073486
6.80000019073486
7.80000019073486
8.80000019073486
9.80000019073486
0.90000000000000002
1.89999997615814
2.90000009536743
3.90000009536743
4.90000009536743
5.90000009536743
6.90000009536743
7.90000009536743
8.89999961853027
9.89999961853027
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
Code: Select all
For c = 1 To 10
Debug StrD(0.1 * c)
Debug StrD(1 + 0.1 * c )
Debug StrD(2 + 0.1 * c )
Debug StrD(3 + 0.1 * c )
Debug StrD(4 + 0.1 * c )
Debug StrD(5 + 0.1 * c )
Debug StrD(6 + 0.1 * c )
Debug StrD(7 + 0.1 * c )
Debug StrD(8 + 0.1 * c )
Debug StrD(9 + 0.1 * c )
Debug ""
Next
You are comparing Debug StrD() to Debug (which then uses something like StrF() ). When Debug prints the float, it is printing all the decimals. When you used Debug StrD() you are using it's default precision and it rounds the value off. Try your example with Debug StrD(0.1 * c,18 ) or Debug StrF(0.1 * c) to see the difference.Falko wrote:Code: Select all
For c = 1 To 10 Debug StrD(0.1 * c) Debug StrD(1 + 0.1 * c ) Debug StrD(2 + 0.1 * c ) Debug StrD(3 + 0.1 * c ) Debug StrD(4 + 0.1 * c ) Debug StrD(5 + 0.1 * c ) Debug StrD(6 + 0.1 * c ) Debug StrD(7 + 0.1 * c ) Debug StrD(8 + 0.1 * c ) Debug StrD(9 + 0.1 * c ) Debug "" Next
Yes you have right with Debug.
I've wrote StrD on this, not StrF and not full Decimals.
This would be rounding and is correct.
You can test this and compare Debug and Debug StrD(...) is not the
same as Debug StrF(..)
The Floats (StrF) are not exactly accurate as Double (StrD).
The Computer is not a "fast" pocket calculator with high precision
Regards, Falko
I've wrote StrD on this, not StrF and not full Decimals.
This would be rounding and is correct.
You can test this and compare Debug and Debug StrD(...) is not the
same as Debug StrF(..)
Code: Select all
For c= 1 To 10
Debug StrD(0.1 * c) + " :Debug StrD"
Debug StrF(0.1 * c) + " :Debug StrF"
Debug "Debug, with no StrF or StrD:"
Debug 0.1*c
Debug StrD(0.1*c,18)+ " Debug StrD with 18 Decimals"
Debug StrF(0.1*c,18)+ " Debug StrF with 18 Decimals"
Debug "-------------------------"
Next c
The Computer is not a "fast" pocket calculator with high precision
Regards, Falko
Tested, removed all double declarations, but with the debugger enabled, compiler still crashes with my program (Sorry, I will post no source because 45000 lines of source code!). Without debugger anything works well.
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Ide shortcut problem
First, Thank you for the update. really rock..
For the good of purebasic here I found small prob on ide.
When I press Alt + F its open a file menu but when I press N to get command New it not work. It goes to all other command in all menu/submenu
other than that its really great. thanks
For the good of purebasic here I found small prob on ide.
When I press Alt + F its open a file menu but when I press N to get command New it not work. It goes to all other command in all menu/submenu
other than that its really great. thanks
Re: Ide shortcut problem
That's not the only one that doesn't work, pressing Alt-C, then E to build an executable doesn't work either.mag wrote:When I press Alt + F its open a file menu but when I press N to get command New it not work. It goes to all other command in all menu/submenu
I've also noticed that the text of the selected menu option stays black so in a black selection back ground you can't see it.

Personally I liked the menu the way it was in v4.10, it worked.

Debugger error
I have this error when I try to run code created on previous version with debug on.
"This executable was not compiled for this version of the debugger!
Please recompile it to match this debugger version."
And I don't know how to recompile it.
"This executable was not compiled for this version of the debugger!
Please recompile it to match this debugger version."
And I don't know how to recompile it.
Re: Debugger error
Use the taskmanager and kill the purebasiccompilationX.exemag wrote:I have this error when I try to run code created on previous version with debug on.
"This executable was not compiled for this version of the debugger!
Please recompile it to match this debugger version."
And I don't know how to recompile it.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: Debugger error
Sounds like you updated the IDE, but not the debugger library or vice versa.mag wrote:I have this error when I try to run code created on previous version with debug on.
"This executable was not compiled for this version of the debugger!
Please recompile it to match this debugger version."
And I don't know how to recompile it.
Try to apply the update again with all PB related programs closed.
quidquid Latine dictum sit altum videtur