How am i going to solve this problem???could somebody please help me,,,
This is the problem...say you are given 1/3, the answer for that was 3.3333 and so on and so forth in other words its infinite,,,how are you going to make it that the answer must be 3.(3) instead of an infinite .3?,,thanks for your help....need asap.
Number Manipulation
Page 1 of 18 Replies - 681 Views - Last Post: 20 August 2010 - 01:31 AM
Replies To: Number Manipulation
#2
Re: Number Manipulation
Posted 06 August 2010 - 01:39 AM
First of all, 1/3 = 0.33333, not 3.33333. You mean you want to format the number of decimal places? You'll be needing DecimalFormat.
Example:
Example:
import java.text.DecimalFormat;
public class something{
public static void main(String[] args){
DecimalFormat df = new DecimalFormat("#.##");
double number = 0.333333333;
//formatting the number into two decimal places
System.out.println(df.format(number));
}
}
This post has been edited by Cuzzie: 06 August 2010 - 01:40 AM
#3
Re: Number Manipulation
Posted 08 August 2010 - 08:11 PM
Cuzzie, on 06 August 2010 - 02:39 AM, said:
First of all, 1/3 = 0.33333, not 3.33333. You mean you want to format the number of decimal places? You'll be needing DecimalFormat.
Example:
Example:
import java.text.DecimalFormat;
public class something{
public static void main(String[] args){
DecimalFormat df = new DecimalFormat("#.##");
double number = 0.333333333;
//formatting the number into two decimal places
System.out.println(df.format(number));
}
}
Even if you have a BidDecimal with 5 billions decimal you will still have decimals missing
My bad sorry
This post has been edited by pbl: 08 August 2010 - 08:26 PM
#4
Re: Number Manipulation
Posted 08 August 2010 - 08:19 PM
Out of curiosity pbl, why is his answer unacceptable? That is how I would format the number
#5
Re: Number Manipulation
Posted 08 August 2010 - 08:23 PM
Luckless, on 08 August 2010 - 09:19 PM, said:
Out of curiosity pbl, why is his answer unacceptable? That is how I would format the number
Sorry my mistake....
I might have been to quick
I saw BigDecimnal instead or DecimalFormat
Please give a +1 to Cuzzie to cancel my -1
My apologies to them
#6
Re: Number Manipulation
Posted 08 August 2010 - 08:26 PM
it's alright, I just didn't want to cancel it out if there was a good reason
Keep it up Cuzzie
#7
Re: Number Manipulation
Posted 08 August 2010 - 08:28 PM
#8
Re: Number Manipulation
Posted 09 August 2010 - 01:00 AM
pbl, on 09 August 2010 - 02:23 AM, said:
Luckless, on 08 August 2010 - 09:19 PM, said:
Out of curiosity pbl, why is his answer unacceptable? That is how I would format the number
Sorry my mistake....
I might have been to quick
I saw BigDecimnal instead or DecimalFormat
Please give a +1 to Cuzzie to cancel my -1
My apologies to them
It's alright.
#9
Re: Number Manipulation
Posted 20 August 2010 - 01:31 AM
sorry...my mistake...yup its 0.3333,,,
thanks for your reply,..
thanks for your reply,..
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|