Skip to content

Commit

Permalink
Fix float reading in cfile
Browse files Browse the repository at this point in the history
Whoah, big surprise float_t and double_t may have different length. Still waiting float32_t and float64_t types from C++23...
  • Loading branch information
winterheart committed Apr 21, 2024
1 parent fecd560 commit fdaf346
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cfile/cfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,8 @@ int8_t cf_ReadByte(CFILE *cfp) {
}
// Read and return a float (32 bits)
// Throws an exception of type (cfile_error *) if the OS returns an error on read
float_t cf_ReadFloat(CFILE *cfp) {
float_t f;
float cf_ReadFloat(CFILE *cfp) {
float f;
cf_ReadBytes((ubyte *)&f, sizeof(f), cfp);
#ifdef MACINTOSH
float e = INTEL_FLOAT(f); // DAJ bash to zero if reads a NaN
Expand All @@ -936,8 +936,8 @@ float_t cf_ReadFloat(CFILE *cfp) {
}
// Read and return a double (64 bits)
// Throws an exception of type (cfile_error *) if the OS returns an error on read
double_t cf_ReadDouble(CFILE *cfp) {
double_t f;
double cf_ReadDouble(CFILE *cfp) {
double f;
cf_ReadBytes((ubyte *)&f, sizeof(f), cfp);
#ifdef OUTRAGE_BIG_ENDIAN
{
Expand Down
4 changes: 2 additions & 2 deletions cfile/cfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ int8_t cf_ReadByte(CFILE *cfp);

// Read and return a float (32 bits)
// Throws an exception of type (cfile_error *) if the OS returns an error on read
float_t cf_ReadFloat(CFILE *cfp);
float cf_ReadFloat(CFILE *cfp);

// Read and return a double (64 bits)
// Throws an exception of type (cfile_error *) if the OS returns an error on read
double_t cf_ReadDouble(CFILE *cfp);
double cf_ReadDouble(CFILE *cfp);

// Reads a string from a CFILE. If the file is type binary, this
// function reads until a NULL or EOF is found. If the file is text,
Expand Down

0 comments on commit fdaf346

Please sign in to comment.