Last active
January 4, 2023 12:51
-
-
Save hnakamur/595a476631d457847152aa7f2bacb60f to your computer and use it in GitHub Desktop.
Calculate log2(1<<49 - 1) in a higher precision than double.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <gmp.h> | |
| #include <mpfr.h> | |
| int main (void) | |
| { | |
| mpfr_t x, y; | |
| mpfr_init2(x, 20); | |
| mpfr_init2(y, 20); | |
| mpfr_set_ui(x, 1UL<<49-1, MPFR_RNDD); | |
| mpfr_log2(y, x, MPFR_RNDD); | |
| mpfr_printf("x=%.0Rf, y=%.20Rf\n", x, y); | |
| mpfr_clear(x); | |
| mpfr_clear(y); | |
| mpfr_free_cache(); | |
| return 0; | |
| } |
hnakamur
commented
Jan 4, 2023
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment