|
-
Jul 9th, 2002, 09:06 AM
#1
Thread Starter
Member
Please Help!!!!
I need a function that take away the decimal from a number... a function that do this...
the number:
12,34555555
the result:
12,3
Can i do this with a javascript function or i have to do it by myself??
Any idea would be useful... thanks...
-
Aug 27th, 2002, 04:21 PM
#2
Hyperactive Member
Ack number one this is a java forum, not a javascript forum, number two I believe that you miswrote you example. If you want a function to take away the decimal, how do you go from 12.3455555 to 12.3 Do you want significant digits or do you want to convert a float to an int?
-
Aug 27th, 2002, 11:03 PM
#3
Dazed Member
Do you mean 12,34555555 as 12.34555555? I think that is what you ment. Yes as billrogers pointed out you would be better asking this in the java script forum. If you were doing this in java then you could cast the double value to an int to lose the precision.
Code:
class decimal{
public static void main(String[] args){
double d = 34.42;
int i = (int)d;
System.out.println(d);
System.out.println(i);
}
}
Last edited by Dilenger4; Aug 27th, 2002 at 11:12 PM.
-
Aug 29th, 2002, 02:43 PM
#4
Hyperactive Member
Yep that would work, I didnt know if he wanted to round just at the decimal though or to a specified significant digit.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|