Wrong overflow message

Just starting out? Need help? Post your questions and find answers here.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Wrong overflow message

Post by Trond »

This is ok:

Code: Select all

a.l = $ffffffff
But this, which should only flip the bits, is not:

Code: Select all

a.l = ~$ffffffff
Changing the value of the individual bits should not result in more bits.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

bug confirmed for 4.02 Win, too

...does the compiler generate quads out of literals?

then ~$ffffffff will result in $ffffffff00000000 wich is too big for long.
oh... and have a nice day.
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: Wrong overflow message

Post by Fig »

Up...
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Wrong overflow message

Post by netmaestro »

Please read before submitting a bug report! wrote:(12) Once a bug as been reported, please don't 'bump' the topic by adding a new post like 'this bug is till not fixed in the new release'. We are aware about it. We read all the bugs, if it's not set as 'Fixed', then we didn't found a solution for now.
One of the very best ways to irritate the team is to bump bug reports.
BERESHEIT
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: Wrong overflow message

Post by Fig »

netmaestro wrote:
Please read before submitting a bug report! wrote:(12) Once a bug as been reported, please don't 'bump' the topic by adding a new post like 'this bug is till not fixed in the new release'. We are aware about it. We read all the bugs, if it's not set as 'Fixed', then we didn't found a solution for now.
One of the very best ways to irritate the team is to bump bug reports.
You are really clever so you know this bug is easy to fix...
I don't want to irritate the team but this probably had slipped off the punch-list since 10 years.
There can be no other explanation. So a polite and gentle bump up is appropriate once every 10 years. (despites the rules, which was made for a purpose, probably prevents bugs to be bumped every days by impatient users)

When you use a long chain of boolean math to achieve a good optimisation, you can get completly insane with that kind of bug.
This is a basic (like addition or divide), not some kind of third party bugged library.
So, please, don't irritate the customer either, we all want Purebasic to get reliable like a professional language.
This is not a decennial attack against the team, it's for everyone's sake. So I assume the team understand and is not irritated. (anyway they can PV me themself if so, which is a smart move to correct someone's behaviour. Isn't it ?)
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Wrong overflow message

Post by Olliv »

I have no computer, but is this bypass ok?

Code: Select all

A.L = -1
A ! (-1)
... and technically faster than 'not' asm statement?
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: Wrong overflow message

Post by Fig »

actually if you do:

Code: Select all

a.l=$ffffffff
a=~a
Debug a
It also works...
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Wrong overflow message

Post by Olliv »

Mh...

Ten years ago, I had a first project on PureBasic which did not work for a problem of background on 3D I could not absolutely solve.

I send different public reports on french and english forum.

No answer.

This project was free for me. The goal : help a friend which thank I reach. He was sure I reached to help him.

Unhappily he died before I could give him whatever I promised.

And I do not believe he is looking me from the sky today.

Also, I did not say anything about this bad story to Fred. And I did not use some words which allow anybody to see the deep and useless feeling I was taken.

Nothing. I had just an answer from NetMaestro which helped me to make transparent bubbles, on the desktop, to give a laugh to Kcc, for which goal?
Nothing.

For money?
No.

There is no goal or money which breaks the death of my friend to see I reach what he wanted.

Today, Fred has perfectly debugged since four years the bug I reported. It was five years toomuch, and too late for me.

I do not think I gave a talk, neither private, neither public to Fred which was otherone than a 'thank you' when I discovered the bug was fixed, even if it changed nothing for me.

It was a pleasure to learn from a person as Mister Gallant, there is an on-line manual to learn myself.
A pleasure to see some pictures created by his wife, especially a flower I just remember, because I did not find the interest to record it, but the lonely interest to remember it.

I talk about this, because it is in this subject. And there is lots of subjects !

Lots of people too which can't talk as we are able to do. And they never had forced me to pay them to have anything.

Also, if I can approach a keyboard, I will 'waste' my time to understand if such a bug is really important. I do not think.

What it is important is when people are agree together. Because, in the discord, all is wasted without break, beginning by the health. That is the point of view of an other 'customer' which can't read your recent source, but which appreciates too, and hope you will reach what you decided for you...
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Wrong overflow message

Post by Lunasole »

Olliv wrote:Mh...
Ten years ago, I had a first project on PureBasic which did not work for a problem of background on 3D I could not absolutely solve.
Probably this will be disappointment for you, but fail of your project is always your fail, not fail of software tools you used for it (used human tools may be a source of fail, but not sw ^^).
Just because it is obvious that any "serious" project (i.e. which requires "lot of efforts" and is quite more complicated than another helloworld) requires that much serious planning/preparations. If you didn't make them well, it is only your problem.

I also failed with one my game I tried time ago (hah, that was noticeable long-run for 6+ months, before finally drown in several different directions ^^) , but for me it was clear at the planning stage that some PB libraries cannot provide enough functionality/abilities, so I just didn't used them. Situation with bugs is the same -- it's not a big deal to do some tests on that "planning stage" to ensure, before you start using some stuff in real project.


PB. But well, about PB bugs, I'm sure the situation was very bad time ago (there are so much old reports, including some guinnessbook-bugs not fixed for 10 years). I'm glad that for recent few years it all looks a lot better (partially because modern PB uses more often those nicely made/debugged open-source libraries [unlike old, which was using mostly own code and that code probably became too complex for a small team to maintain], and partially because code skills of team evolved). As for me, nowadays most of really important/impassable things are fixed fast enough
(so in that direction PB is enough "professional" and reliable, thats for @Fig. even with temporary workarounds you need sometime like in this case, total waste of time/efforts is much more less than you waste if do equal things in any other known "true professional codemonkey approved" language with zero probability to struggle any language/runtime bugs).
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Wrong overflow message

Post by Olliv »

@Fig

1) On PureBasic 5.50 x64, to invert quads $FFFFFFFF and $FFFFFFFFFFFFFFFF : works perfectly fine.

2) To read an hexa long value, as written in the doc, we must specify #PB_Long, because the default format is quad. If problem occurs, a complete message in the bug doc area is certainly welcomen. Technically, if you want to treat with unsigned, you can do it in assembly, what is the best solution to optimize. You will see then a constant is unabled in the 'all bit inverting' 'not' statement : if problem, you are the customer of Intel or AMD which uses Intel stantard, so write to Intel.

3) To check what is a long in PB, we can see this doc page : Variables and types, what it allows us to forsee what is the numeric defining domain for long types. As we can see in this old fake subject, it is sure that an overflow on x86 causes an overflow message.

$FFFFFFFF = unsigned format
-1 = signed format
Fred
Administrator
Administrator
Posts: 16616
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Wrong overflow message

Post by Fred »

All numerics are treated as quad internally, that's why the affection doesn't work.
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 664
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

Re: Wrong overflow message

Post by Kurzer »

@Fred: Does this mean, using an Integer variable (because it's the nativ and fastes datatype of the currently used CPU) is actually sensless?

I stumbled over this thread because I have a similar problem.
If I compare two unsigned integer values on a x86 system I get a wrong result, even if I try to unsign the variable using & $ffffffff
Please compile the following code with a x86 and a x64 Compiler and compare the results:

Code: Select all

; Compile this in x86 mode and then in x64 mode

EnableExplicit

#Max = $FFFFFFFE

Procedure.s TestI(Value.i)
	CompilerIf #PB_Processor_x64
		If Value & $ffffffffffffffff > #Max & $ffffffffffffffff
	CompilerElse	
		If Value & $ffffffff > #Max & $ffffffff
	CompilerEndIf
		ProcedureReturn Str(Value) + " is greater than " + Str(#Max)
	Else
		ProcedureReturn Str(Value) + " is lower than " + Str(#Max)
	EndIf
EndProcedure

Procedure.s TestL(Value.l)
	If Value & $ffffffff > #Max & $ffffffff
		ProcedureReturn Str(Value) + " is greater than " + Str(#Max)
	Else
		ProcedureReturn Str(Value) + " is lower than " + Str(#Max)
	EndIf
EndProcedure

Procedure.s TestQ(Value.q)
	If Value & $ffffffffffffffff > #Max & $ffffffffffffffff
		ProcedureReturn Str(Value) + " is greater than " + Str(#Max)
	Else
		ProcedureReturn Str(Value) + " is lower than " + Str(#Max)
	EndIf
EndProcedure

Debug TestI($4)
Debug TestL($4)
Debug TestQ($4)
The x86 Result wrote: [12:39:46] [Debug] 4 is greater than 4294967294
[12:39:46] [Debug] 4 is greater than 4294967294
[12:39:46] [Debug] 4 is lower than 4294967294
The x64 Result wrote: [12:39:46] [Debug] 4 is lower than 4294967294
[12:39:46] [Debug] 4 is lower than 4294967294
[12:39:46] [Debug] 4 is lower than 4294967294
The Result of TestI() and TestL() on a x86 system will be wrong. On a x64 system all results are okay.

Is using a quad variable really the only solution to compare two unsigned long values on a x86 system?
And how I can compare two unsigned quad values?

Code: Select all

#QMax = $FFFFFFFFFFFFFFFE
If Value & $ffffffffffffffff > #QMax & $ffffffffffffffff
Does not work.
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2023: 56y
"Happiness is a pet." | "Never run a changing system!"
Post Reply