Skip to content

Commit a3432cd

Browse files
committed
improve docs
1 parent e0ea8ba commit a3432cd

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/main/java/com/upokecenter/util/ExtendedDecimal.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,8 +1488,17 @@ public double ToDouble() {
14881488
/**
14891489
* Creates a decimal number from a 32-bit floating-point number. This method
14901490
* computes the exact value of the floating point number, not an
1491-
* approximation, as is often the case by converting the number to a
1492-
* string.
1491+
* approximation, as is often the case by converting the floating point
1492+
* number to a string first. Remember, though, that the exact value of a
1493+
* 32-bit floating-point number is not always the value you get when you
1494+
* pass a literal decimal number (for example, calling
1495+
* <code>ExtendedDecimal.FromSingle(0.1f)</code>), since not all decimal
1496+
* numbers can be converted to exact binary numbers (in the example
1497+
* given, the resulting ExtendedDecimal will be the the value of the
1498+
* closest "float" to 0.1, not 0.1 exactly). To create an
1499+
* ExtendedDecimal number from a decimal number, use FromString instead
1500+
* in most cases (for example: <code>ExtendedDecimal.FromString("0.1")</code>
1501+
*).
14931502
* @param flt A 32-bit floating-point number.
14941503
* @return A decimal number with the same value as {@code flt} .
14951504
*/
@@ -1585,8 +1594,16 @@ public static ExtendedDecimal FromInt32(int valueSmaller) {
15851594
/**
15861595
* Creates a decimal number from a 64-bit floating-point number. This method
15871596
* computes the exact value of the floating point number, not an
1588-
* approximation, as is often the case by converting the number to a
1589-
* string.
1597+
* approximation, as is often the case by converting the floating point
1598+
* number to a string first. Remember, though, that the exact value of a
1599+
* 64-bit floating-point number is not always the value you get when you
1600+
* pass a literal decimal number (for example, calling
1601+
* <code>ExtendedDecimal.FromDouble(0.1f)</code>), since not all decimal
1602+
* numbers can be converted to exact binary numbers (in the example
1603+
* given, the resulting ExtendedDecimal will be the value of the closest
1604+
* "double" to 0.1, not 0.1 exactly). To create an ExtendedDecimal
1605+
* number from a decimal number, use FromString instead in most cases
1606+
* (for example: <code>ExtendedDecimal.FromString("0.1")</code>).
15901607
* @param dbl A 64-bit floating-point number.
15911608
* @return A decimal number with the same value as {@code dbl} .
15921609
*/

src/main/java/com/upokecenter/util/ExtendedFloat.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,8 @@ public double ToDouble() {
789789
/**
790790
* Creates a binary float from a 32-bit floating-point number. This method
791791
* computes the exact value of the floating point number, not an
792-
* approximation, as is often the case by converting the number to a
793-
* string.
792+
* approximation, as is often the case by converting the floating point
793+
* number to a string first.
794794
* @param flt A 32-bit floating-point number.
795795
* @return A binary float with the same value as {@code flt} .
796796
*/
@@ -871,8 +871,8 @@ public static ExtendedFloat FromInt32(int valueSmaller) {
871871
/**
872872
* Creates a binary float from a 64-bit floating-point number. This method
873873
* computes the exact value of the floating point number, not an
874-
* approximation, as is often the case by converting the number to a
875-
* string.
874+
* approximation, as is often the case by converting the floating point
875+
* number to a string first.
876876
* @param dbl A 64-bit floating-point number.
877877
* @return A binary float with the same value as {@code dbl} .
878878
*/

0 commit comments

Comments
 (0)