次の方法で共有


Double.ToString(Double) Method

Definition

Returns a string representation of the double argument.

[Android.Runtime.Register("toString", "(D)Ljava/lang/String;", "")]
public static string ToString (double d);
[<Android.Runtime.Register("toString", "(D)Ljava/lang/String;", "")>]
static member ToString : double -> string

Parameters

d
Double

the double to be converted.

Returns

a string representation of the argument.

Attributes

Remarks

Returns a string representation of the double argument. All characters mentioned below are ASCII characters. <ul> <li>If the argument is NaN, the result is the string "NaN". <li>Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument. If the sign is negative, the first character of the result is '-' ('\u005Cu002D'); if the sign is positive, no sign character appears in the result. As for the magnitude m: <ul> <li>If m is infinity, it is represented by the characters "Infinity"; thus, positive infinity produces the result "Infinity" and negative infinity produces the result "-Infinity".

<li>If m is zero, it is represented by the characters "0.0"; thus, negative zero produces the result "-0.0" and positive zero produces the result "0.0".

<li>If m is greater than or equal to 10<sup>-3</sup> but less than 10<sup>7</sup>, then it is represented as the integer part of m, in decimal form with no leading zeroes, followed by '.' ('\u005Cu002E'), followed by one or more decimal digits representing the fractional part of m.

<li>If m is less than 10<sup>-3</sup> or greater than or equal to 10<sup>7</sup>, then it is represented in so-called "computerized scientific notation." Let n be the unique integer such that 10<sup>n</sup> &le; m< 10<sup>n+1</sup>; then let a be the mathematically exact quotient of m and 10<sup>n</sup> so that 1 &le; a< 10. The magnitude is then represented as the integer part of a, as a single decimal digit, followed by '.' ('\u005Cu002E'), followed by decimal digits representing the fractional part of a, followed by the letter 'E' ('\u005Cu0045'), followed by a representation of n as a decimal integer, as produced by the method Integer#toString(int). </ul> </ul> How many digits must be printed for the fractional part of m or a? There must be at least one digit to represent the fractional part, and beyond that as many, but only as many, more digits as are needed to uniquely distinguish the argument value from adjacent values of type double. That is, suppose that x is the exact mathematical value represented by the decimal representation produced by this method for a finite nonzero argument d. Then d must be the double value nearest to x; or if two double values are equally close to x, then d must be one of them and the least significant bit of the significand of d must be 0.

To create localized string representations of a floating-point value, use subclasses of java.text.NumberFormat.

Java documentation for java.lang.Double.toString(double).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to