Fixed a divide by 0 error
This commit is contained in:
parent
d261293d6b
commit
c5b9187216
1 changed files with 3 additions and 3 deletions
|
|
@ -399,14 +399,14 @@ namespace FixedPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator float() const {
|
explicit operator float() const {
|
||||||
if(isReciprocal)
|
if(isReciprocal && val != UnderlyingNumber(0))
|
||||||
return 1.0f / static_cast<float>(val);
|
return 1.0f / static_cast<float>(val);
|
||||||
else
|
else
|
||||||
return static_cast<float>(val);
|
return static_cast<float>(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator double() const {
|
explicit operator double() const {
|
||||||
if(isReciprocal)
|
if(isReciprocal && val != UnderlyingNumber(0))
|
||||||
return 1.0 / static_cast<double>(val);
|
return 1.0 / static_cast<double>(val);
|
||||||
else
|
else
|
||||||
return static_cast<double>(val);
|
return static_cast<double>(val);
|
||||||
|
|
@ -427,7 +427,7 @@ namespace FixedPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator UnderlyingNumber() const {
|
explicit operator UnderlyingNumber() const {
|
||||||
if(isReciprocal)
|
if(isReciprocal && val != UnderlyingNumber(0))
|
||||||
return UnderlyingNumber(1) / val;
|
return UnderlyingNumber(1) / val;
|
||||||
else
|
else
|
||||||
return val;
|
return val;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue