Skip to content

Commit 6677090

Browse files
committed
Use powf instead of powi
1 parent bfd6660 commit 6677090

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,13 @@ impl Printf for f64 {
309309
}
310310

311311
if use_scientific {
312-
let normal = abs / 10.0_f64.powi(exponent);
312+
let normal = abs / 10.0_f64.powf(exponent as f64);
313313

314314
number.push_str(&format!("{}", normal.trunc()));
315315
if precision > 0 {
316316
number.push('.');
317317
let mut tail =
318-
((normal - normal.trunc()) * 10.0_f64.powi(precision)).round() as u64;
318+
((normal - normal.trunc()) * 10.0_f64.powf(precision as f64)).round() as u64;
319319
let mut rev_tail_str = String::new();
320320
for _ in 0..precision {
321321
rev_tail_str.push((b'0' + (tail % 10) as u8) as char);
@@ -332,7 +332,7 @@ impl Printf for f64 {
332332
number.push_str(&format!("{}", abs.trunc()));
333333
if precision > 0 {
334334
number.push('.');
335-
let mut tail = ((abs - abs.trunc()) * 10.0_f64.powi(precision)).round() as u64;
335+
let mut tail = ((abs - abs.trunc()) * 10.0_f64.powf(precision as f64)).round() as u64;
336336
let mut rev_tail_str = String::new();
337337
for _ in 0..precision {
338338
rev_tail_str.push((b'0' + (tail % 10) as u8) as char);

0 commit comments

Comments
 (0)