Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

floating-point-comparison

Comparing floats in a pandas column

September 11, 2023 by Tarik

Due to imprecise float comparison you can or your comparison with np.isclose, isclose takes a relative and absolute tolerance param so the following should work: df[‘result’] = df[‘actual_credit’].ge(df[‘min_required_credit’]) | np.isclose(df[‘actual_credit’], df[‘min_required_credit’])

Categories python Tags floating-point, floating-point-comparison, inexact-arithmetic, pandas, python Leave a comment

What’s the difference between identical(x, y) and isTRUE(all.equal(x, y))?

July 25, 2023 by Tarik
Categories r Tags built-in, comparison, equality, floating-point-comparison, r Leave a comment

Why does Release/Debug have a different result for std::min?

July 23, 2023 by Tarik

In IEEE 754 comparing NAN to anything will always yield false, no matter what it is. slope > 0; // false slope < 0; // false slope == 0; // false And, more importantly for you slope < DBL_MAX; // false DBL_MAX < slope; // false So it seems that the compiler reorders the parameters/uses … Read more

Categories c++ Tags c++, floating-point-comparison, min, nan Leave a comment

In C++, is exactly one of guaranteed to be true on floats?

May 27, 2023 by Tarik

No. It’s enough for either a or b to be NaN for each of a < b, a == b and a > b to be false. If both a and b are non-NaN then exactly one of a < b, a == b or a > b has to be true. In complement, this … Read more

Categories c++ Tags c++, floating-point, floating-point-comparison, standards Leave a comment

Floating point equality

May 23, 2023 by Tarik

However, I wonder, are there any cases, when using == is perfectly fine? Sure there are. One category of examples are usages that involve no computation, e.g. setters that should only execute on changes: void setRange(float min, float max) { if(min == m_fMin && max == m_fMax) return; m_fMin = min; m_fMax = max; // … Read more

Categories c++ Tags c++, floating-point, floating-point-comparison, language-lawyer, precision Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa