Posts: 61
Threads: 6
Joined: Jan 2005
When you do this:
Code:
dim onebyte as ubyte
onebyte = 255
onebyte +=10
print onebyte
Then onebyte is 9, I understand that this is because of an overflow, but woulden't it be better if it stopped at 255?
Code:
print cubyte(265) 'convert value to a ubyte value
This also returns 9, here at least wouldent it be better if it returned 255?
Posts: 922
Threads: 15
Joined: Jun 2003
If you want it completely different than in any other language and running at 1/5 of the atual speed, yeah.. there's no instruction to do satured operations in most CPU's, but when working with packed data, SIMD, where wrap-around is not always wanted..
Posts: 294
Threads: 9
Joined: Oct 2002
adding numbers is done by the CPU, and its been the same since forever. If you want something different, design your own CPU
.
Posts: 658
Threads: 71
Joined: Sep 2003
You could do smth like this:
Code:
declare sub addwith255limit (byref var, val)
if (int(var) + int(val)) > 255 then exit sub
var += val
end sub
url]http://fbide.sourceforge.net/[/url]
Posts: 61
Threads: 6
Joined: Jan 2005
Ok I'll stop whining
I'll just have to make a function checking the value myself
Quote:adding numbers is done by the CPU, and its been the same since forever. If you want something different, design your own CPU .
hmmm a good idea!