Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
119 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,68 @@ | ||
/**************************************************** | ||
* This work is licensed under the Creative | ||
* Commons Attribution-NonCommercial-ShareAlike | ||
* 3.0 Unported License. To view a copy of this | ||
* license, visit | ||
* http://creativecommons.org/licenses/by-nc-sa/3.0/ | ||
* or send a letter to Creative Commons, 444 | ||
* Castro Street, Suite 900, Mountain View, | ||
* California, 94041, USA. | ||
* Copyright 2018 Ben M. Ward | ||
* | ||
* This work is licensed under the Creative | ||
* Commons Attribution-NonCommercial-ShareAlike | ||
* 3.0 Unported License. To view a copy of this | ||
* license, visit | ||
* http://creativecommons.org/licenses/by-nc-sa/3.0/ | ||
* or send a letter to Creative Commons, 444 | ||
* Castro Street, Suite 900, Mountain View, | ||
* California, 94041, USA. | ||
***************************************************/ | ||
#include "math.h" | ||
#include "src/lib/math/math.h" | ||
|
||
float DESCENT_FIXED::get_Value() | ||
{ | ||
return static_cast<double>(((float)value.raw) / 65536.0); | ||
using ::std::istream; | ||
using ::std::ostream; | ||
|
||
namespace DESCENT_BOT { | ||
namespace SRC { | ||
namespace LIB { | ||
namespace MATH { | ||
|
||
float DESCENT_FIXED::get_Value() { | ||
return static_cast<double>((static_cast<float>(value.raw)) / 65536.0); | ||
} | ||
|
||
void DESCENT_FIXED::set_Value(float f) | ||
{ | ||
value.raw = static_cast<int>(f * 65536); | ||
void DESCENT_FIXED::set_Value(float f) { | ||
value.raw = static_cast<int>(f * 65536); | ||
} | ||
|
||
void DESCENT_FIXED::set_Value(int i) | ||
{ | ||
value.parts.hi = i; | ||
value.parts.lo = 0; | ||
void DESCENT_FIXED::set_Value(int i) { | ||
value.parts.hi = i; | ||
value.parts.lo = 0; | ||
} | ||
|
||
/******************************** | ||
* This method compartmentalizes | ||
* the loading of fixed data types | ||
*******************************/ | ||
istream &operator>>(istream &input, DESCENT_FIXED &fixed) | ||
{ | ||
input.read((char *)&fixed.value.raw, sizeof(fixed.value.raw)); | ||
return input; | ||
istream &operator>>(istream &input, DESCENT_FIXED &fixed) { | ||
input.read(reinterpret_cast<char *>(&fixed.value.raw), | ||
sizeof(fixed.value.raw)); | ||
return input; | ||
} | ||
|
||
/******************************** | ||
* This method compartmentalizes | ||
* the displaying of fixed data types | ||
*******************************/ | ||
ostream &operator<<(ostream &output, DESCENT_FIXED &fixed) | ||
{ | ||
output << fixed.get_Value(); | ||
return output; | ||
ostream &operator<<(ostream &output, DESCENT_FIXED &fixed) { | ||
output << fixed.get_Value(); | ||
return output; | ||
} | ||
|
||
/******************************** | ||
* This method compartmentalizes | ||
* the loading of fixed data types | ||
*******************************/ | ||
istream &operator>>(istream &input, DESCENT_SHORTFIXED &fixed) | ||
{ | ||
input.read((char *)&fixed.value.raw, sizeof(fixed.value.raw)); | ||
return input; | ||
istream &operator>>(istream &input, DESCENT_SHORTFIXED &fixed) { | ||
input.read(reinterpret_cast<char *>(&fixed.value.raw), | ||
sizeof(fixed.value.raw)); | ||
return input; | ||
} | ||
|
||
} // namespace MATH | ||
} // namespace LIB | ||
} // namespace SRC | ||
} // namespace DESCENT_BOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters