| Anonymous | Login | Signup for a new account | 2013-05-24 21:30 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||||||
| 0001154 | OCaml | OCaml general | public | 2002-05-15 10:05 | 2012-05-12 01:30 | |||||||
| Reporter | administrator | |||||||||||
| Assigned To | ||||||||||||
| Priority | normal | Severity | feature | Reproducibility | always | |||||||
| Status | resolved | Resolution | suspended | |||||||||
| Platform | OS | OS Version | ||||||||||
| Product Version | ||||||||||||
| Target Version | Fixed in Version | |||||||||||
| Summary | 0001154: string_of_float loosing precision | |||||||||||
| Description | Full_Name: mattias waldau Version: 3.04 OS: linux Submission from: h175n2fls34o849.telia.com (217.208.235.175) It seems that string_of_float is only working with float internally, and not using double. string_of_float (86928280876. +. 0.9513) results in 86928280877 | |||||||||||
| Tags | No tags attached. | |||||||||||
| Attached Files | ||||||||||||
Relationships |
|||||||||||
|
|||||||||||
Notes |
|
|
(0000124) administrator (administrator) 2002-06-27 10:50 |
string_of_float is just printf "%.12g", hence limited precision. An "exact" conversion would be nice but isn't provided by the C standard library. |
|
(0006754) doligez (manager) 2012-01-20 14:26 |
At this point, string_of_float is a quick-and-dirty function. If you need more precision, you should use printf and specify the number of digits. Maybe someday, someone will implement [Clinger1990] and [Steele1990] for OCaml and submit a patch, but don't hold your breath. @inproceedings{Clinger1990, author = {Clinger, William D.}, title = {How to read floating point numbers accurately}, booktitle = {Proceedings of the ACM SIGPLAN 1990 conference on Programming language design and implementation}, series = {PLDI '90}, year = {1990}, isbn = {0-89791-364-7}, location = {White Plains, New York, United States}, pages = {92--101}, numpages = {10}, url = {http://doi.acm.org/10.1145/93542.93557}, [^] doi = {http://doi.acm.org/10.1145/93542.93557}, [^] acmid = {93557}, publisher = {ACM}, address = {New York, NY, USA}, } @inproceedings{Steele1990, author = {Steele,Jr., Guy L. and White, Jon L.}, title = {How to print floating-point numbers accurately}, booktitle = {Proceedings of the ACM SIGPLAN 1990 conference on Programming language design and implementation}, series = {PLDI '90}, year = {1990}, isbn = {0-89791-364-7}, location = {White Plains, New York, United States}, pages = {112--126}, numpages = {15}, url = {http://doi.acm.org/10.1145/93542.93559}, [^] doi = {http://doi.acm.org/10.1145/93542.93559}, [^] acmid = {93559}, publisher = {ACM}, address = {New York, NY, USA}, } |
|
(0007413) dbuenzli (reporter) 2012-05-04 16:15 |
Somehow I still think it would be nice if : (float_of_string (string_of_float i)) = i could be true for all the integers i that can be represented exactly in OCaml's float value. These integers are in the interval [-2^53;2^53]. This could be achieved by using "%.16g", i.e. is true for : (float_of_string (Printf.sprintf "%.16g" i)) Best, Daniel |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2005-11-18 10:13 | administrator | New Issue | |
| 2012-01-20 14:16 | doligez | Relationship added | related to 0004345 |
| 2012-01-20 14:26 | doligez | Note Added: 0006754 | |
| 2012-01-20 14:26 | doligez | Status | acknowledged => resolved |
| 2012-01-20 14:26 | doligez | Resolution | open => suspended |
| 2012-01-20 14:26 | doligez | Description Updated | View Revisions |
| 2012-01-26 18:30 | doligez | Relationship added | related to 0001829 |
| 2012-05-04 16:15 | dbuenzli | Note Added: 0007413 | |
| Copyright © 2000 - 2011 MantisBT Group |