Mercurial Hosting > luan
comparison core/src/luan/Luan.java @ 255:e5ad26746c94
improve toString(Number)
git-svn-id: https://luan-java.googlecode.com/svn/trunk@256 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Mon, 27 Oct 2014 21:19:42 +0000 |
parents | 392105b660d7 |
children | 4dfa86dbca45 |
comparison
equal
deleted
inserted
replaced
254:e0fb8a49e031 | 255:e5ad26746c94 |
---|---|
78 } | 78 } |
79 | 79 |
80 public static String toString(Number n) { | 80 public static String toString(Number n) { |
81 if( n instanceof Integer ) | 81 if( n instanceof Integer ) |
82 return n.toString(); | 82 return n.toString(); |
83 int i = n.intValue(); | |
84 if( i == n.doubleValue() ) | |
85 return Integer.toString(i); | |
83 String s = n.toString(); | 86 String s = n.toString(); |
84 int iE = s.indexOf('E'); | 87 int iE = s.indexOf('E'); |
85 String ending = null; | 88 String ending = null; |
86 if( iE != -1 ) { | 89 if( iE != -1 ) { |
87 ending = s.substring(iE); | 90 ending = s.substring(iE); |