FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 4 : int() and float() do not always work properly in the preprocessor
Last modified: 2010-03-13 05:26
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
FIXED -
Pr
i
ority:
P3
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
fry
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2005-05-12 18:37
straighten out int() -> toInt() conversion in the preproc
also additional float casting problems, i.e:
float u = float(x)/width; works.
float u = (float(x)/width); doesn't work: "unexpected token: float".
float u = (x/float(width)); works!
Additional Comment
#1 From fry 2005-05-12 18:40
return (int(5.5)) causes an error
http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1083624993;start=0
Additional Comment
#2 From fry 2005-05-24 18:43
more reports of sadness:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display
;
num=1116887165;start=0#3
float(i*oneCycle*freq)
where i and freq are int and freq is float, it says: perhaps you wanted the overload version
"float toFloat(boolean $1);" instead?
and with the int conversion:
int(i*oneCycle*freq)
doesn't give any problem.
Additional Comment
#3 From fry 2005-07-15 15:06
http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1084011098
Additional Comment
#4 From jedierikb 2005-09-28 21:43
perhaps related...
in 0091 Beta (windowsxp)...
String test = "5.0";
int testi = int( test );
println( test + " -> " + testi ); //5.0 -> 0
Additional Comment
#5 From fry 2006-03-16 08:31
(In reply to
comment #4
)
> perhaps related...
>
> in 0091 Beta (windowsxp)...
>
> String test = "5.0";
> int testi = int( test );
> println( test + " -> " + testi ); //5.0 -> 0
nope, that's your own bug.. you can't parse a float as an int. you have to parse it as a float
and then cast it as an int. though i guess that makes for a weird setup because the parsing
and the casting are the same.. hrmmm..
Additional Comment
#6 From fry 2006-09-19 10:45
***
Bug 397
has been marked as a duplicate of this bug. ***
Additional Comment
#7 From galanter 2008-10-04 07:44
Possibly related n 0135 Beta (Mac OS X):
int yframe = 500;
int xframe = 500;
float frameLength = 6.0;
float frameCenter = 0.0;
float evalMaxx = frameCenter + ( frameLength * ( float(xframe) / float(yframe) ) );
yields "unexpected token: float"
Additional Comment
#8 From galanter 2008-10-04 07:46
likely related:
int yframe = 500;
int xframe = 500;
float frameLength = 6.0;
float frameCenter = 0.0;
float evalMaxx = frameCenter + ( frameLength * ( float(xframe) / float(yframe) ) );
yields "unexpected token: float"
Additional Comment
#9 From fry 2008-10-04 09:25
yup, though this all hinges on
bug #598
, which is basically that the
grammar needs to be completely redone.
Additional Comment
#10 From MrFeinberg 2010-03-12 12:58
I seem to have accidentally killed this bug when I stabbed #598. Fixed?
Additional Comment
#11 From fry 2010-03-13 05:26
yep, these ones are at least confirmed to work. great!