Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation on ARM based systems #1093

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/StringRoutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,20 @@ int DigitWidth(long int numberIn) {
return (minusSign + numi);
}

// FloatWidth()
/** \return the number of characters necessary to express given float. */
int FloatWidth(double floatIn) {
double float_exponent = fabs( log10( floatIn ) );
++float_exponent;
return (int)float_exponent; // Cast to int implicitly rounds down
/** \return the number of characters necessary for a minimal representation of
* the fractional part of a floating point number, i.e. the number of
* leading zeros plus 1. characters necessary to express given float.
*/
int MinNumFracChars(double floatIn) {
// Split number into integer and fractional part
double intpart = 0;
double frac = modf(floatIn, &intpart);
// Leading zeros
int n_leading_zeros = 0;
double absfrac = fabs(frac);
if (absfrac > 0)
n_leading_zeros = (int)ceil( fabs( log10( absfrac ) ) ) - 1;
return n_leading_zeros + 1;
}

// ---------- STRING CONVERSION ROUTINES ---------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/StringRoutines.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ std::string AppendNumber(std::string const &, int);
int WildcardMatch(std::string const&, std::string const&);
/// \return number of characters needed to represent given digit.
int DigitWidth(long int);
/// \return number of characters needed to represent given floating point.
int FloatWidth(double);
/// \return Min number of chars needed to represent fractional part of given floating point.
int MinNumFracChars(double);
/// Remove any trailing whitespace from string.
void RemoveTrailingWhitespace(std::string &);
/// \return string stripped of trailing whitespace.
Expand Down
2 changes: 1 addition & 1 deletion src/TextFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void TextFormat::SetCoordFormat(size_t maxFrames, double min, double step,
int col_width = DigitWidth( (long int)maxCoord );
// Check if the precision is enough to support the step size.
if (step < 1.0) {
int prec_exp_width = FloatWidth( step );
int prec_exp_width = MinNumFracChars( step );
if (prec_exp_width > col_precision)
col_precision = prec_exp_width;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Whenever a number that precedes <revision> is incremented, all subsequent
* numbers should be reset to 0.
*/
#define CPPTRAJ_INTERNAL_VERSION "V6.27.3"
#define CPPTRAJ_INTERNAL_VERSION "V6.28.0"
/// PYTRAJ relies on this
#define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION
#endif
Loading