sorry one better
this might show a way to avoid using the VAL possibly for input as literal and the first code may be a way to better assign a EXT from a string input
but does not solve rounding
if input is a string, maybe best to split string into two integer values and divide by number of decimal places used in input string
fire at will
code to show using literals
this might show a way to avoid using the VAL possibly for input as literal and the first code may be a way to better assign a EXT from a string input
but does not solve rounding
if input is a string, maybe best to split string into two integer values and divide by number of decimal places used in input string
fire at will
Code:
'spit input into j and i 'the string is "16.585" then split string into integers j=16585 i=3 if i>0 then n=j/10^i else n=j end if
Code:
#COMPILE EXE #DIM ALL FUNCTION PBMAIN () AS LONG LOCAL j AS LONG LOCAL m AS EXT LOCAL n AS EXT j=16585 'ok n=j/1000 'ok 'above delivers 16.585 into EXT variable n m=16.585 'bad input 'm=16.585## 'bad input as well PRINT m PRINT STR$(m,18) PRINT n PRINT STR$(n,18) IF m=n THEN PRINT "match" IF m<>n THEN PRINT "no match" m=VAL("16.585") 'ok probably and should be slower than other ways PRINT m PRINT STR$(m,18) PRINT n PRINT STR$(n,18) IF m=n THEN PRINT "match" IF m<>n THEN PRINT "no match" m=16585##/1000## 'ok PRINT m PRINT STR$(m,18) PRINT n PRINT STR$(n,18) IF m=n THEN PRINT "match" IF m<>n THEN PRINT "no match" m=16585/1000 'ok PRINT m PRINT STR$(m,18) PRINT n PRINT STR$(n,18) IF m=n THEN PRINT "match" IF m<>n THEN PRINT "no match" m=16585 'ok m=m/1000 'ok PRINT m PRINT STR$(m,18) PRINT n PRINT STR$(n,18) IF m=n THEN PRINT "match" IF m<>n THEN PRINT "no match" WAITKEY$ END FUNCTION
Comment