Conversation
|
See also the discussion for Base. |
|
Sorry if I missed this in the linked discussions, but why is the result of, say, |
| let epsilon_float = | ||
| float_of_bits 0x3C_B0_00_00_00_00_00_00L | ||
|
|
||
| let pi = 0x3.243f6a8885a308d313198a2e037073 |
There was a problem hiding this comment.
Is there more precision in this definition than what OCaml doubles can represent?
# Printf.sprintf "%h" 0x3.243f6a8885a308d313198a2e037073;;
- : string = "0x1.921fb54442d18p+1"Do 0x3.243f6a8885a308d313198a2e037073 and 0x1.921fb54442d18p+1 represent different floating-point numbers? The latter is also exactly what I get on my machine with 4. *. atan 1. (but maybe atan's precision depends on the system and shouldn't be relied on for a definition?).
|
On 2016-12-11, Gabriel Scherer wrote:
+let pi = 0x3.243f6a8885a308d313198a2e037073
Is there more precision in this definition than what OCaml doubles can
represent?
Yes.
```ocaml
# Printf.sprintf "%h" 0x3.243f6a8885a308d313198a2e037073;;
- : string = "0x1.921fb54442d18p+1"
```
Do `0x3.243f6a8885a308d313198a2e037073` and `0x1.921fb54442d18p+1`
represent different floating-point number?
Not for the double precision. I can use 0x1.921fb54442d18p+1 if you
prefer (less obvious that it is π but the very value stored into
memory).
The latter is also exactly what I get on my machine with `4. *. atan
1.` (but maybe `atan`'s precision depends on the system and shouldn't
be relied on for a definition?).
The same result is also given by acos(-1.) on amd64/Linux. I don't know for other platform/OS.
|
|
Are we happy with the extra item in the global namespace introduced by this patch? |
I'd rather have a Float module for this. |
I agree that having one module in the stdlib for each built-in type is a good direction (if only to allow Adding modules to the stdlib (esp. with very common names) can conflict with existing user modules. Perhaps a good time to study ways to add modules to the stdlib without risking such conflict. One possibility would be to name the new module |
|
At the developer meeting two days ago, we decided this PR will be suspended until a |
|
Now that #1010 is merged, I'm "unsuspending" this PR. It is now possible to add a Float submodule in Stdlib without polluting the global namespace. |
|
There is now a @Chris00 : could you amend this PR to add the new value to that module (only)? |
|
Superseded by #1674 |
…l#964) * using HTML list tags on search results page * ol instead of ul * headings package overview
Fixes #4170