Results 1 to 2 of 2
Thread: [Q] - pi as a float
- 09-30-2011, 10:16 AM #1
Member
- Join Date
- Sep 2011
- Posts
- 2
- Rep Power
- 0
[Q] - pi as a float
Forgive me if this has been asked, but I searched for pi and Math.PI and class and float and couldn't find anything relevant.
Problem as follows:
input:
a number which is a radius
output:
area and circumference of the circle with input as radius
volume and surface area of the sphere with input as radius
I got a working class, but when I attempted to change the variables to floats, in the interest of learning, it errored out. The reason is that Math.PI yields a double. I tried:
float pi = Math.PIF
That doesn't work. The only way I was able to have a working class using floats, I had to initialize pi as follows:
pi = 22/7F
Is there a way to use Java's Math.PI as a float?
- 09-30-2011, 10:33 AM #2
Member
- Join Date
- Sep 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
regarding int and float
By lakshmibvaraprasad in forum New To JavaReplies: 2Last Post: 07-24-2011, 08:30 PM -
string to float
By Sungron in forum New To JavaReplies: 3Last Post: 02-02-2010, 09:23 AM -
Working with float
By dardar in forum New To JavaReplies: 8Last Post: 01-27-2010, 08:29 PM -
Float vs. Double
By javanub in forum New To JavaReplies: 1Last Post: 11-23-2008, 12:11 PM -
Class float
By Peter in forum New To JavaReplies: 1Last Post: 07-08-2007, 01:17 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks