doc: tweak mul_{acc,add} signed overflow avoidance

This commit is contained in:
Trevor Spiteri 2021-04-20 16:26:53 +02:00
parent e4a4c95323
commit 57ec630b67
2 changed files with 37 additions and 32 deletions

View File

@ -353,9 +353,9 @@ assert_eq!(Fix::from_num(7.5).div_euclid_int(2), Fix::from_num(3));
",
if_signed_else_empty_str! {
$Signedness;
"The product `a` × `b` does not need to be representable for
a valid computation: if the product would overflow but the final result would
not overflow, this method still returns the correct result.
"For some cases, the product `a` × `b` would overflow on its
own, but the final result `self` + `a` × `b` is representable; in these cases
this method saves the correct result without overflow.
",
},
@ -606,9 +606,9 @@ When overflow occurs, `self` is not modified and retains its previous value.
"#,
if_signed_else_empty_str! {
$Signedness;
"The product `a` × `b` does not need to be representable for
a valid computation: if the product would overflow but the final result would
not overflow, this method still returns the correct result.
"For some cases, the product `a` × `b` would overflow on its
own, but the final result `self` + `a` × `b` is representable; in these cases
this method saves the correct result without overflow.
",
},
@ -1038,9 +1038,9 @@ saturating on overflow.
",
if_signed_else_empty_str! {
$Signedness;
"The product `a` × `b` does not need to be representable for
a valid computation: if the product would overflow but the final result would
not overflow, this method still returns the correct result.
"For some cases, the product `a` × `b` would overflow on its
own, but the final result `self` + `a` × `b` is representable; in these cases
this method saves the correct result without overflow.
",
},
@ -1571,9 +1571,9 @@ panicking on overflow.
",
if_signed_else_empty_str! {
$Signedness;
"The product `a` × `b` does not need to be representable for
a valid computation: if the product would overflow but the final result would
not overflow, this method still returns the correct result.
"For some cases, the product `a` × `b` would overflow on its
own, but the final result `self` + `a` × `b` is representable; in these cases
this method saves the correct result without overflow.
",
},
@ -2050,9 +2050,9 @@ wrapping and returning [`true`] if overflow occurs.
",
if_signed_else_empty_str! {
$Signedness;
"The product `a` × `b` does not need to be representable for
a valid computation: if the product would overflow but the final result would
not overflow, this method still returns the correct result.
"For some cases, the product `a` × `b` would overflow on its
own, but the final result `self` + `a` × `b` is representable; in these cases
this method saves the correct result without overflow.
",
},

View File

@ -734,10 +734,9 @@ assert_eq!(a.wide_mul(b), 1.328_125);
",
if_signed_else_empty_str! {
$Signedness;
"The product `self` × `mul` does not need to be
representable for a valid computation: if the product would overflow
but the final result would not overflow, this method still returns the
correct result.
"For some cases, the product `self` × `mul` would overflow
on its own, but the final result `self` × `mul` + `add` is representable; in
these cases this method returns the correct result without overflow.
",
},
@ -1215,10 +1214,9 @@ Returns `self` × `mul` + `add`, or [`None`] on overflow.
",
if_signed_else_empty_str! {
$Signedness;
"The product `self` × `mul` does not need to be
representable for a valid computation: if the product would overflow
but the final result would not overflow, this method still returns the
correct result.
"For some cases, the product `self` × `mul` would overflow
on its own, but the final result `self` × `mul` + `add` is representable; in
these cases this method returns the correct result without overflow.
",
},
@ -1589,10 +1587,9 @@ Returns `self` × `mul` + `add`, saturating on overflow.
",
if_signed_else_empty_str! {
$Signedness;
"The product `self` × `mul` does not need to be
representable for a valid computation: if the product would overflow
but the final result would not overflow, this method still returns the
correct result.
"For some cases, the product `self` × `mul` would overflow
on its own, but the final result `self` × `mul` + `add` is representable; in
these cases this method returns the correct result without overflow.
",
},
@ -2151,10 +2148,9 @@ Returns `self` × `mul` + `add`, panicking on overflow.
",
if_signed_else_empty_str! {
$Signedness;
"The product `self` × `mul` does not need to be
representable for a valid computation: if the product would overflow
but the final result would not overflow, this method still returns the
correct result.
"For some cases, the product `self` × `mul` would overflow
on its own, but the final result `self` × `mul` + `add` is representable; in
these cases this method returns the correct result without overflow.
",
},
@ -2562,7 +2558,16 @@ Returns a [tuple] of `self` × `mul` + `add` and a [`bool`] indicating
whether an overflow has occurred. On overflow, the wrapped value is
returned.
The `mul` parameter can have a fixed-point type like
",
if_signed_else_empty_str! {
$Signedness;
"For some cases, the product `self` × `mul` would overflow
on its own, but the final result `self` × `mul` + `add` is representable; in
these cases this method returns the correct result without overflow.
",
},
"The `mul` parameter can have a fixed-point type like
`self` but with a different number of fractional bits.
# Examples