mirror of
https://github.com/hch12907/orbum.git
synced 2024-06-02 19:38:16 -04:00
Corrected float reading
This commit is contained in:
parent
2ac3746d30
commit
1ac9c98300
|
@ -27,12 +27,14 @@ public:
|
|||
/// Read/write floats - wrappers around read/write uword.
|
||||
f32 read_float(const size_t offset)
|
||||
{
|
||||
return static_cast<f32>(read_uword(offset));
|
||||
uword raw = read_uword(offset);
|
||||
return *reinterpret_cast<f32*>(&raw);
|
||||
}
|
||||
|
||||
void write_float(const size_t offset, const f32 value)
|
||||
{
|
||||
write_uword(offset, static_cast<uword>(value));
|
||||
f32 raw = value;
|
||||
write_uword(offset, *reinterpret_cast<uword*>(&raw));
|
||||
}
|
||||
|
||||
/// ByteBusMappable overrides.
|
||||
|
|
|
@ -24,12 +24,14 @@ public:
|
|||
/// Read/write floats - wrappers around read/write uword.
|
||||
f32 read_float()
|
||||
{
|
||||
return static_cast<f32>(read_uword());
|
||||
uword raw = read_uword();
|
||||
return *reinterpret_cast<f32*>(&raw);
|
||||
}
|
||||
|
||||
void write_float(const f32 value)
|
||||
{
|
||||
write_uword(static_cast<uword>(value));
|
||||
f32 raw = value;
|
||||
write_uword(*reinterpret_cast<uword*>(&raw));
|
||||
}
|
||||
|
||||
/// Bitfield extraction/insertion.
|
||||
|
|
Loading…
Reference in a new issue