Skip to content

Commit 8fcd288

Browse files
committed
---
yaml --- r: 56455 b: refs/heads/auto c: b7cf89f h: refs/heads/master i: 56453: 6357307 56451: 8c93f73 56447: 0e10a78 v: v3
1 parent 90aab45 commit 8fcd288

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 6cc7107aa6ca78093cb81aed44170099b8fad68a
17+
refs/heads/auto: b7cf89f6e8c076cfd844b884474279687554597e
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/num/f32.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,22 @@ impl Float for f32 {
543543
fn is_finite(&self) -> bool {
544544
!(self.is_NaN() || self.is_infinite())
545545
}
546+
547+
///
548+
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding error. This
549+
/// produces a more accurate result with better performance than a separate multiplication
550+
/// operation followed by an add.
551+
///
552+
#[inline(always)]
553+
fn mul_add(&self, a: f32, b: f32) -> f32 {
554+
mul_add(*self, a, b)
555+
}
556+
557+
/// Returns the next representable floating-point value in the direction of `other`
558+
#[inline(always)]
559+
fn next_after(&self, other: f32) -> f32 {
560+
nextafter(*self, other)
561+
}
546562
}
547563

548564
//

branches/auto/src/libcore/num/f64.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,22 @@ impl Float for f64 {
583583
fn is_finite(&self) -> bool {
584584
!(self.is_NaN() || self.is_infinite())
585585
}
586+
587+
///
588+
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding error. This
589+
/// produces a more accurate result with better performance than a separate multiplication
590+
/// operation followed by an add.
591+
///
592+
#[inline(always)]
593+
fn mul_add(&self, a: f64, b: f64) -> f64 {
594+
mul_add(*self, a, b)
595+
}
596+
597+
/// Returns the next representable floating-point value in the direction of `other`
598+
#[inline(always)]
599+
fn next_after(&self, other: f64) -> f64 {
600+
nextafter(*self, other)
601+
}
586602
}
587603

588604
//

branches/auto/src/libcore/num/float.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,22 @@ impl Float for float {
735735
fn is_finite(&self) -> bool {
736736
!(self.is_NaN() || self.is_infinite())
737737
}
738+
739+
///
740+
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding error. This
741+
/// produces a more accurate result with better performance than a separate multiplication
742+
/// operation followed by an add.
743+
///
744+
#[inline(always)]
745+
fn mul_add(&self, a: float, b: float) -> float {
746+
mul_add(*self as f64, a as f64, b as f64) as float
747+
}
748+
749+
/// Returns the next representable floating-point value in the direction of `other`
750+
#[inline(always)]
751+
fn next_after(&self, other: float) -> float {
752+
nextafter(*self as f64, other as f64) as float
753+
}
738754
}
739755
740756
#[cfg(test)]

branches/auto/src/libcore/num/num.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ pub trait Fractional: Num
105105
fn recip(&self) -> Self;
106106
}
107107

108+
///
109+
/// Defines constants and methods common to real numbers
110+
///
108111
pub trait Real: Signed
109112
+ Fractional {
110113
// FIXME (#5527): usages of `int` should be replaced with an associated
@@ -237,8 +240,7 @@ pub trait Int: Integer
237240
+ BitCount {}
238241

239242
///
240-
/// Primitive floating point numbers. This trait should only be implemented
241-
/// for the `f32`, `f64`, and `float` types.
243+
/// Primitive floating point numbers
242244
///
243245
pub trait Float: Real
244246
+ Signed
@@ -252,6 +254,9 @@ pub trait Float: Real
252254
fn is_NaN(&self) -> bool;
253255
fn is_infinite(&self) -> bool;
254256
fn is_finite(&self) -> bool;
257+
258+
fn mul_add(&self, a: Self, b: Self) -> Self;
259+
fn next_after(&self, other: Self) -> Self;
255260
}
256261

257262
///

0 commit comments

Comments
 (0)