doc: tweak mul_{acc,add} signed overflow avoidance
This commit is contained in:
parent
e4a4c95323
commit
57ec630b67
|
@ -353,9 +353,9 @@ assert_eq!(Fix::from_num(7.5).div_euclid_int(2), Fix::from_num(3));
|
||||||
",
|
",
|
||||||
if_signed_else_empty_str! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `a` × `b` does not need to be representable for
|
"For some cases, the product `a` × `b` would overflow on its
|
||||||
a valid computation: if the product would overflow but the final result would
|
own, but the final result `self` + `a` × `b` is representable; in these cases
|
||||||
not overflow, this method still returns the correct result.
|
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! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `a` × `b` does not need to be representable for
|
"For some cases, the product `a` × `b` would overflow on its
|
||||||
a valid computation: if the product would overflow but the final result would
|
own, but the final result `self` + `a` × `b` is representable; in these cases
|
||||||
not overflow, this method still returns the correct result.
|
this method saves the correct result without overflow.
|
||||||
|
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
|
@ -1038,9 +1038,9 @@ saturating on overflow.
|
||||||
",
|
",
|
||||||
if_signed_else_empty_str! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `a` × `b` does not need to be representable for
|
"For some cases, the product `a` × `b` would overflow on its
|
||||||
a valid computation: if the product would overflow but the final result would
|
own, but the final result `self` + `a` × `b` is representable; in these cases
|
||||||
not overflow, this method still returns the correct result.
|
this method saves the correct result without overflow.
|
||||||
|
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
|
@ -1571,9 +1571,9 @@ panicking on overflow.
|
||||||
",
|
",
|
||||||
if_signed_else_empty_str! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `a` × `b` does not need to be representable for
|
"For some cases, the product `a` × `b` would overflow on its
|
||||||
a valid computation: if the product would overflow but the final result would
|
own, but the final result `self` + `a` × `b` is representable; in these cases
|
||||||
not overflow, this method still returns the correct result.
|
this method saves the correct result without overflow.
|
||||||
|
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
|
@ -2050,9 +2050,9 @@ wrapping and returning [`true`] if overflow occurs.
|
||||||
",
|
",
|
||||||
if_signed_else_empty_str! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `a` × `b` does not need to be representable for
|
"For some cases, the product `a` × `b` would overflow on its
|
||||||
a valid computation: if the product would overflow but the final result would
|
own, but the final result `self` + `a` × `b` is representable; in these cases
|
||||||
not overflow, this method still returns the correct result.
|
this method saves the correct result without overflow.
|
||||||
|
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
|
|
|
@ -734,10 +734,9 @@ assert_eq!(a.wide_mul(b), 1.328_125);
|
||||||
",
|
",
|
||||||
if_signed_else_empty_str! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `self` × `mul` does not need to be
|
"For some cases, the product `self` × `mul` would overflow
|
||||||
representable for a valid computation: if the product would overflow
|
on its own, but the final result `self` × `mul` + `add` is representable; in
|
||||||
but the final result would not overflow, this method still returns the
|
these cases this method returns the correct result without overflow.
|
||||||
correct result.
|
|
||||||
|
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
|
@ -1215,10 +1214,9 @@ Returns `self` × `mul` + `add`, or [`None`] on overflow.
|
||||||
",
|
",
|
||||||
if_signed_else_empty_str! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `self` × `mul` does not need to be
|
"For some cases, the product `self` × `mul` would overflow
|
||||||
representable for a valid computation: if the product would overflow
|
on its own, but the final result `self` × `mul` + `add` is representable; in
|
||||||
but the final result would not overflow, this method still returns the
|
these cases this method returns the correct result without overflow.
|
||||||
correct result.
|
|
||||||
|
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
|
@ -1589,10 +1587,9 @@ Returns `self` × `mul` + `add`, saturating on overflow.
|
||||||
",
|
",
|
||||||
if_signed_else_empty_str! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `self` × `mul` does not need to be
|
"For some cases, the product `self` × `mul` would overflow
|
||||||
representable for a valid computation: if the product would overflow
|
on its own, but the final result `self` × `mul` + `add` is representable; in
|
||||||
but the final result would not overflow, this method still returns the
|
these cases this method returns the correct result without overflow.
|
||||||
correct result.
|
|
||||||
|
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
|
@ -2151,10 +2148,9 @@ Returns `self` × `mul` + `add`, panicking on overflow.
|
||||||
",
|
",
|
||||||
if_signed_else_empty_str! {
|
if_signed_else_empty_str! {
|
||||||
$Signedness;
|
$Signedness;
|
||||||
"The product `self` × `mul` does not need to be
|
"For some cases, the product `self` × `mul` would overflow
|
||||||
representable for a valid computation: if the product would overflow
|
on its own, but the final result `self` × `mul` + `add` is representable; in
|
||||||
but the final result would not overflow, this method still returns the
|
these cases this method returns the correct result without overflow.
|
||||||
correct result.
|
|
||||||
|
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
|
@ -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
|
whether an overflow has occurred. On overflow, the wrapped value is
|
||||||
returned.
|
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.
|
`self` but with a different number of fractional bits.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
Loading…
Reference in New Issue