-
JSON Object floating 연산 오류 해결Java 2018. 6. 14. 18:49
/** * Put a key/double pair in the JSONObject. * * @param key A key string. * @param value A float which is the value. * @return this. * @throws JSONException If the key is null or if the number is invalid. */ public JSONObject put(String key, float value) throws JSONException { this.put(key, Double.parseDouble(String.valueOf(value))); return this; }
putting float values into a JSONObject is using the put(String, double) method.
Unfortunately, this type of cast causes floating point precision problems.
For example, the float number 6.99 is translated to the double 6.989999771118164'Java' 카테고리의 다른 글
5 Thread Constructors (0) 2014.04.20 Thread API enumerate (0) 2014.04.20 Dynamic class loading 이란 (0) 2013.12.24 BiiSet Class (0) 2013.09.28 HashSet (0) 2013.09.28