Skip to content

Commit 25e21bf

Browse files
committed
Update script
1 parent 975a47d commit 25e21bf

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

etc/generate-constants.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,32 @@ function update_rem_pio2(cfg::Config)::String
7575
to_bits = "$ty_name::to_bits"
7676
end
7777

78-
hi_int(x::BigFloat) = @sprintf "(%s(hf%d!(\"%a\")) >> %d) as u%d" to_bits info.bits x halfbits halfbits
78+
bigf_hi(x::BigFloat) = @sprintf "(%s(hf%d!(\"%a\")) >> %d) as u%d" to_bits info.bits x halfbits halfbits
79+
bigf_hex(x::BigFloat) = @sprintf "hf%d!(\"%a\")" info.bits x
7980

8081
setprecision(ty_info(fty).sig_bits + 1)
8182

8283
ty_impl = """
8384
impl RemPio2Support for $ty_name {
8485
const TO_INT: Self = 1.5 / $ty_name::EPSILON;
85-
const INV_PIO2: Self = 6.36619772367581382433e-01;
86+
const INV_PIO2: Self = $(bigf_hex(2 / big(pi)));
8687
const PIO2_1: Self = 1.57079632673412561417e+00;
8788
const PIO2_1T: Self = 6.07710050650619224932e-11;
8889
const PIO2_2: Self = 6.07710050630396597660e-11;
8990
const PIO2_2T: Self = 2.02226624879595063154e-21;
9091
const PIO2_3: Self = 2.02226624871116645580e-21;
9192
const PIO2_3T: Self = 8.47842766036889956997e-32;
9293
93-
const FRAC_5PI_4_HI: HalfRep<Self> = $(hi_int(big(pi)*5/4));
94-
const FRAC_3PI_4_HI: HalfRep<Self> = $(hi_int(big(pi)*3/4));
95-
const FRAC_9PI_4_HI: HalfRep<Self> = $(hi_int(big(pi)*9/4));
96-
const FRAC_7PI_4_HI: HalfRep<Self> = $(hi_int(big(pi)*7/4));
97-
const FRAC_3PI_2_HI: HalfRep<Self> = $(hi_int(big(pi)*3/2));
98-
const TAU_HI: HalfRep<Self> = $(hi_int(big(pi)*2));
94+
const FRAC_5PI_4_HI: HalfRep<Self> = $(bigf_hi(5 * big(pi) / 4));
95+
const FRAC_3PI_4_HI: HalfRep<Self> = $(bigf_hi(3 * big(pi) / 4));
96+
const FRAC_9PI_4_HI: HalfRep<Self> = $(bigf_hi(9 * big(pi) / 4));
97+
const FRAC_7PI_4_HI: HalfRep<Self> = $(bigf_hi(7 * big(pi) / 4));
98+
const FRAC_3PI_2_HI: HalfRep<Self> = $(bigf_hi(3 * big(pi) / 2));
99+
const TAU_HI: HalfRep<Self> = $(bigf_hi(2 * big(pi)));
99100
const FRAC_PI_2_HI: HalfRep<Self> = 0x921fb;
100-
const FRAC_2_POW_20_PI_2: HalfRep<Self> = $(hi_int((big(2)^20) * pi / 2));
101+
const FRAC_2_POW_20_PI_2: HalfRep<Self> = $(bigf_hi((big(2)^20) * pi / 2));
101102
102-
const MAGIC_F: Self = hf64!("0x1p24");
103+
const MAGIC_F: Self = hf$(info.bits)!("0x1p24");
103104
104105
fn large(x: &[Self], y: &mut [Self], e0: i32, prec: usize) -> i32 {
105106
super::super::super::rem_pio2_large(x, y, e0, prec)

libm/src/math/generic/generated/rem_pio2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::support::{HalfRep, f64_to_bits};
33

44
impl RemPio2Support for f64 {
55
const TO_INT: Self = 1.5 / f64::EPSILON;
6-
const INV_PIO2: Self = 6.36619772367581382433e-01;
6+
const INV_PIO2: Self = hf64!("0xa.2f9836e4e4418p-4");
77
const PIO2_1: Self = 1.57079632673412561417e+00;
88
const PIO2_1T: Self = 6.07710050650619224932e-11;
99
const PIO2_2: Self = 6.07710050630396597660e-11;

0 commit comments

Comments
 (0)