Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.
Format:min integer digits 6
Format:min integer digits 5
NumberFormat format1 = NumberFormat.getInstance();
All this code does is create an instance of NumberFormat Class. This is going to be one of the parameters passed to displayNumbers.Format:default
formatted:0 | unformatted:0.0
formatted:3.142 | unformatted:3.141592653589793
formatted:25.133 | unformatted:25.132741228718345
formatted:254.469 | unformatted:254.46900494077323
formatted:3,216.991 | unformatted:3216.990877275948
formatted:49,087.385 | unformatted:49087.385212340516
formatted:879,444.881 | unformatted:879444.8810753123
formatted:18,110,656.471 | unformatted:1.8110656471007094E7
formatted:421,657,428.266 | unformatted:4.216574282663131E8
formatted:10,954,056,258.833 | unformatted:1.0954056258833088E10
formatted:314,159,265,358.979 | unformatted:3.141592653589793E11
The second call they changed NumberFormat so that these 2 lines were executed: format2.setMinimumFractionDigits(2);
format2.setMaximumFractionDigits(4);
Format:min fraction digits 2, max fraction digits 4
formatted:0.00 | unformatted:0.0
formatted:3.1416 | unformatted:3.141592653589793
formatted:25.1327 | unformatted:25.132741228718345
formatted:254.469 | unformatted:254.46900494077323
formatted:3,216.9909 | unformatted:3216.990877275948
formatted:49,087.3852 | unformatted:49087.385212340516
formatted:879,444.8811 | unformatted:879444.8810753123
formatted:18,110,656.471 | unformatted:1.8110656471007094E7
formatted:421,657,428.2663 | unformatted:4.216574282663131E8
formatted:10,954,056,258.8331 | unformatted:1.0954056258833088E10
formatted:314,159,265,358.9793 | unformatted:3.141592653589793E11
Each subsequent call shows a different setting for NumberFormat.
NumberFormat is the abstract base class for all number formats. This class provides the interface for formatting and parsing numbers
DisplayNumbers itself takes 2 parameters.
format2.setMinimumFractionDigits(2);
format2.setMaximumFractionDigits(4);
format2.setMinimumFractionDigits(2);
format2.setMaximumFractionDigits(4);
Each subsequent call shows a different setting for NumberFormat.what is the meaning of setting for format.
what is the meaning of parsing the numbers.'Parsing' a number means to take the String representation of the number, ie. String numString = "42.7", and convert that into a numerical data type, so the result would be the same as doing... double numDouble = 42.7;
DisplayNumbers itself takes 2 parameters.That's because it isn't a method of NumberFormat, it is just the method that they defined in the tutorial that you linked to. Take a look at the code in that tutorial again.
I do not see the above method in below link
http://docs.oracle.com/javase/7/docs/api/java/text/NumberFormat.html
what is meaning of setting maximum fraction digitsSetting the maximum fraction digits, affects how the conversion from a number to a String happens, eg. in the above they are setting 4 as the max fraction digits on the formatter, so say you had... double num = 98.7654321; and then you formatted with the above formatter, the result would be a String that contained... "98.7654" ie. it has only included 4 fraction digits or in other words, 4 decimal places.
In this question you have asked the following:
I wonder what is math.pow function is. I have not understood below output
how we got it
what is the difference between above two loops. Why they have separate loops for 'default' and then also 'off'. please advise
what is the meaning of parsing the numbers. Please advise
what is meaning of setting maximum fraction digits.
http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html
Here is excerpt from above page:
static double pow(double a, double b)
Returns the value of the first argument raised to the power of the second argument.
In the loop in your example
Open in new window
they are counting from zero to ten.each iteration through the loop assigns a new value to num
so just concentrating of the math.pow part of the loop...
on the first iteration they are taking zero and raising it to the power of zero which equals 1
on the 2nd iteration they take one and raise it to the power of one which equals 1
on the 3rd iteration they take two and raise it to the power of two which equals 4
on the 4th iteration they take three and raise it to the power of three which equals 27
This continues on for the remainder of the loop.
Note that the above is ONLY for the math.pow part of the equation. they also take the result of it times 0, 1, 2, 3 and times the value of PI for each iteration as well.
So completing the first 4 iteration computations:
where the math.pow result is:
We also need to apply the remaining part of the equation giving these approx values (approx because I used 3.14 instead of Math.PI)
3.14 * 1 * 0 = 0
3.14 * 1 * 1 = 3.14
3.14 * 4 * 2 = 25.12
3.14 * 27 * 3 = 254.34