67 |
67 |
68 import static org.testng.Assert.assertEquals; |
68 import static org.testng.Assert.assertEquals; |
69 import static org.testng.Assert.assertTrue; |
69 import static org.testng.Assert.assertTrue; |
70 |
70 |
71 /** |
71 /** |
72 * FastDtoa tests |
72 * BignumDtoa tests |
73 */ |
73 */ |
74 @SuppressWarnings("javadoc") |
74 @SuppressWarnings("javadoc") |
75 public class BignumDtoaTest { |
75 public class BignumDtoaTest { |
76 |
76 |
77 final static private int BUFFER_SIZE = 100; |
77 final static private int BUFFER_SIZE = 100; |
216 |
216 |
217 DoubleConversion.bignumDtoa(3.5844466002796428e+298, DtoaMode.PRECISION, 10, buffer); |
217 DoubleConversion.bignumDtoa(3.5844466002796428e+298, DtoaMode.PRECISION, 10, buffer); |
218 assertTrue(10 >= buffer.getLength()); |
218 assertTrue(10 >= buffer.getLength()); |
219 assertEquals("35844466", trimRepresentation(buffer.getRawDigits())); |
219 assertEquals("35844466", trimRepresentation(buffer.getRawDigits())); |
220 assertEquals(299, buffer.getDecimalPoint()); |
220 assertEquals(299, buffer.getDecimalPoint()); |
|
221 buffer.reset(); |
|
222 |
|
223 DoubleConversion.bignumDtoa(1e-23, DtoaMode.SHORTEST, 0, buffer); |
|
224 assertEquals("1", buffer.getRawDigits()); |
|
225 assertEquals(-22, buffer.getDecimalPoint()); |
221 buffer.reset(); |
226 buffer.reset(); |
222 |
227 |
223 final long smallest_normal64 = 0x0010000000000000L; |
228 final long smallest_normal64 = 0x0010000000000000L; |
224 double v = Double.longBitsToDouble(smallest_normal64); |
229 double v = Double.longBitsToDouble(smallest_normal64); |
225 DoubleConversion.bignumDtoa(v, DtoaMode.SHORTEST, 0, buffer); |
230 DoubleConversion.bignumDtoa(v, DtoaMode.SHORTEST, 0, buffer); |