The slowest part of that is unquestionably the VAL function, which is
designed to work with integers, floating point, hexadecimal and so
forth: a complex function. Since you don't need anything nearly that
fancy here, you might want to build your own specialized VAL replacement.
------------------
Tom Hanlin
PowerBASIC Staff
Announcement
Collapse
No announcement yet.
More speed
Collapse
X
-
Thanks Lance for the quick replay ..
Your routine more smart but it is as quick as mine on my old P166.
I'll try it on my P300 tomorrow.
Both need about 5 sec per 1 000 000 passes.
I know that my idea is unusual but I've to change
string$ e.g. " 123" to a? - variable.
Regards
Matthias Kuhn
------------------
Leave a comment:
-
What about something like this... there should be no range errors if BY$ exceeds the range of a 16-bit integer.
Code:function test_byte?(byval by$) public function = max%(0, min%(val(by$),255)) end function
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment:
-
More speed
Hi all,
how can I made this much more quicker ??
I want to test if the num-range is ok for
byte?-variables.
function test_byte?(byval by$ ) public
local a%
a%=val(by$)
if a%>255 then
function=255
elseif a%<0 then
function=0
else
function=a%
end if
end function
I`ve tested with on local error but I
get the always the err=6 Over... by 256 and
-1
Thank for help
Matthias Kuhn
------------------
Tags: None
Leave a comment: