FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 293 : Ceil() needs adjustment?
Last modified: 2006-02-19 18:12
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
INVALID -
Pr
i
ority:
P2
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
splat
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2006-02-19 17:32
See sample code:
--------------------------------------
float test;
test = 30/17;
println(test + " ceil:" + ceil(test));
test = 30f/17f;
println(test + " ceil:" + ceil(test));
Additional Comment
#1 From fry 2006-02-19 17:40
i'm getting:
1.0 ceil:1
1.7647059 ceil:2
which is correct.
are you not understanding floats vs integers correctly?
http://processing.org/faq/bugs.html#integers
Additional Comment
#2 From splat 2006-02-19 18:01
Ahh... sorry to bug you.
Maybe this should be added to the Float docs (or somewhere more appropriate)?
...a float variable recieving an (int) floor result seems really unintuitive (but
apparently makes sense). Sorry agian.
Additional Comment
#3 From fry 2006-02-19 18:12
ah, i gotcha. the issue is that the ceil() is defined as the next integer up, so we pass back an
integer, since you're 1) more likely than not to *want* an integer as the result in terms of how
you use it and 2) if you want a float to come back as the result, you can just take the result as
a float:
float blah = ceil(1.7);