Quantcast
Channel: web development helpdesk » double
Browsing all 6 articles
Browse latest View live

How to convert a String to a double in Java?

The Double class contains a number of (static) methods for converting to/from various formats. To convert to a double use static method Double.parseDouble() String s = "123.456"; try { double d =...

View Article



How to convert a double to a String in Java?

Use static method Double.toString() double d = 123.456; String s = java.lang.Double.toString(d); // An alternative would be to // use the following string concatenation String s2 = "" + d;

View Article

How to format a double as a String?

Create an instance of DecimalFormat with the required format and use its format() method to format the double value. See the DecimalFormat javadoc for details on specifying format. double d =...

View Article

How to convert double to byte array

The Double class contains two methods that return a representation of a floating point value according to the IEEE 754 floating-point “double format” bit layout. The first, doubleToLongBits() does not...

View Article

How to round decimal value using BigDecimal

You can use the setScale() method to control the rounding of a decimal value as shown in the following example: double value = 123.456789; BigDecimal bd = new BigDecimal(value).setScale(2,...

View Article


How to format value as a percentage

When you need to format a number as a percent you can use the ‘%’ symbol in your DecimalFormat string. The static helper method getPercentInstance() can also be used if you don’t need complete control...

View Article
Browsing all 6 articles
Browse latest View live




Latest Images