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 {
|
||||
if(isReciprocal)
|
||||
if(isReciprocal && val != UnderlyingNumber(0))
|
||||
return 1.0f / static_cast<float>(val);
|
||||
else
|
||||
return static_cast<float>(val);
|
||||
}
|
||||
|
||||
explicit operator double() const {
|
||||
if(isReciprocal)
|
||||
if(isReciprocal && val != UnderlyingNumber(0))
|
||||
return 1.0 / static_cast<double>(val);
|
||||
else
|
||||
return static_cast<double>(val);
|
||||
|
|
@ -427,7 +427,7 @@ namespace FixedPoint {
|
|||
}
|
||||
|
||||
explicit operator UnderlyingNumber() const {
|
||||
if(isReciprocal)
|
||||
if(isReciprocal && val != UnderlyingNumber(0))
|
||||
return UnderlyingNumber(1) / val;
|
||||
else
|
||||
return val;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue