FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   400/360 is NOT 1.0
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: 400/360 is NOT 1.0  (Read 270 times)
st33d

WWW Email
400/360 is NOT 1.0
« on: Jun 3rd, 2004, 9:15pm »

I'm trying to make a graph to try out different equations and ways to plot them.
  I'm ploting sine through 360 degrees and so to fit the graph on the page i do (hieght/360)*i and The graph falls short. I try printing it and get integers. So I print (400/360);
 
1.0
 
What?
  I try this on the desktop calculator and I get 1.11111++. I try making a float and printing that.
 
1.0
 
I'm assuming it's a syntax thing. Is it Processing or me?
 

I could murder a pint.
sspboyd


Re: 400/360 is NOT 1.0
« Reply #1 on: Jun 3rd, 2004, 9:25pm »

try this:
Code:
println((float)400/360);

or this:
Code:
println(400/360.0);

 
The output for both is 1.1111112
 
You can use (double) if you want greater accuracy
 
steve
 

gmail.com w/ sspboyd username
Mythmon


Re: 400/360 is NOT 1.0
« Reply #2 on: Jun 3rd, 2004, 11:27pm »

venner is right, i just want to clarify his answer
p5 will use the lowest accuracy given so
int/int=int
int/float=float
float/int=float
float/float=float
float/double=double
double/float=double
ect
 
Pages: 1 

« Previous topic | Next topic »