diff options
| author | Alasdair Armstrong | 2018-06-27 19:40:54 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-06-27 19:40:54 +0100 |
| commit | 028c67766b0bcbd453dbdeab609267bdce56b290 (patch) | |
| tree | 366ea6c130683581e72c78196e359eaa6bf70f6a /lib | |
| parent | 84e5c99514eddd1c8ea962dcf3e787bc5bc91101 (diff) | |
Actually fix real literals, and add a test for various properties
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sail.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -969,10 +969,13 @@ void real_power(real *rop, const real base, const sail_int exp) void CREATE_OF(real, sail_string)(real *rop, const sail_string op) { + int decimal; + int total; + mpq_init(*rop); - gmp_sscanf(op, "%Zd.%Zd", sail_lib_tmp1, sail_lib_tmp2); + gmp_sscanf(op, "%Zd.%n%Zd%n", sail_lib_tmp1, &decimal, sail_lib_tmp2, &total); - unsigned long len = (unsigned long) mpz_sizeinbase(sail_lib_tmp2, 10); + int len = total - decimal; mpz_ui_pow_ui(sail_lib_tmp3, 10, len); mpz_set(mpq_numref(*rop), sail_lib_tmp2); mpz_set(mpq_denref(*rop), sail_lib_tmp3); |
