File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
main/java/com/dampcake/bencode
test/java/com/dampcake/bencode Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 2121import java .io .InputStream ;
2222import java .io .InvalidObjectException ;
2323import java .io .PushbackInputStream ;
24+ import java .math .BigDecimal ;
2425import java .nio .ByteBuffer ;
2526import java .nio .charset .Charset ;
2627import java .util .ArrayList ;
@@ -198,7 +199,7 @@ public Long readNumber() throws IOException {
198199 buffer .append ((char ) token );
199200 }
200201
201- return Long . parseLong (buffer .toString ());
202+ return new BigDecimal (buffer .toString ()). longValue ( );
202203 }
203204
204205 /**
Original file line number Diff line number Diff line change @@ -243,6 +243,13 @@ public void run() throws Exception {
243243 assertEquals (0 , instance .available ());
244244 }
245245
246+ @ Test
247+ public void testReadNumberScientificNotation () throws Exception {
248+ instantiate ("i-2.9155148901435E+18e" );
249+
250+ assertEquals (-2915514890143500000L , instance .readNumber ().longValue ());
251+ }
252+
246253 @ Test
247254 @ SuppressWarnings ("unchecked" )
248255 public void testReadList () throws Exception {
You can’t perform that action at this time.
0 commit comments