Commits

Kirill Simonov committed 3c56d2e

Dynamically determine the inf and nan values. Should fix #14.
Thanks to Scott Daniels for the report and the patch.

Comments (0)

Files changed (2)

lib/yaml/constructor.py

         else:
             return sign*int(value)
 
-    inf_value = 1e300000
+    inf_value = 1e300
+    while repr(inf_value) != repr(inf_value*inf_value):
+        inf_value *= inf_value
     nan_value = inf_value/inf_value
 
     def construct_yaml_float(self, node):

lib/yaml/representer.py

     def represent_long(self, data):
         return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data))
 
-    repr_pos_inf = repr(1e300000)
-    repr_neg_inf = repr(-1e300000)
-    repr_nan = repr(1e300000/1e300000)
+    inf_value = 1e300
+    while repr(inf_value) != repr(inf_value*inf_value):
+        inf_value *= inf_value
+    nan_value = inf_value/inf_value
+
+    repr_pos_inf = repr(inf_value)
+    repr_neg_inf = repr(-inf_value)
+    repr_nan = repr(inf_value/inf_value)
 
     def represent_float(self, data):
         repr_data = repr(data)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.