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

detail/voronoi_robust_fpt.hpp #48

Open
LLlKuIIeP opened this issue Jul 30, 2020 · 7 comments
Open

detail/voronoi_robust_fpt.hpp #48

LLlKuIIeP opened this issue Jul 30, 2020 · 7 comments

Comments

@LLlKuIIeP
Copy link

Доброе время суток.

Коллеги из соседнего отдела нашли особенность, там деление на 0 происходит.

182 строка

  robust_fpt operator-(const robust_fpt& that) const {
    floating_point_type fpv = this->fpv_ - that.fpv_;
    relative_error_type re;
    if ((!is_neg(this->fpv_) && !is_pos(that.fpv_)) ||
        (!is_pos(this->fpv_) && !is_neg(that.fpv_))) {
      re = (std::max)(this->re_, that.re_) + ROUNDING_ERROR;
    } else {
      floating_point_type temp =
        0;          //
      if (fpv != 0) // этот случай в библиотеке не обработан
        temp =      //
        (this->fpv_ * this->re_ + that.fpv_ * that.re_) / fpv;
      if (is_neg(temp))
        temp = -temp;
      re = temp + ROUNDING_ERROR;
    }
    return robust_fpt(fpv, re);
  }

Сможете посмотреть и поправить?

@asydorchuk
Copy link
Member

Yes, I will look into it.

Да, я посмотрю.

@LLlKuIIeP
Copy link
Author

Good afternoon.

Are there any successes?

@eadf
Copy link

eadf commented Mar 24, 2021

Is there really an issue with divide by zero here?
To me it looks like the err value intentionally is set to infinity whenever additions or subtractions results in zero.
What took me a while to figure out was if the divide by zero could result in NaN (0/0).

That would be a problem, since NaN compared to any ulp value would be false, but it doesn't look like it can happen

@LLlKuIIeP
Copy link
Author

LLlKuIIeP commented Mar 29, 2021

Good day.

Let's connect colleagues to clarify division by zero.

@meretin-as
Copy link

Is there really an issue with divide by zero here?
To me it looks like the err value intentionally is set to infinity whenever additions or subtractions results in zero.
What took me a while to figure out was if the divide by zero could result in NaN (0/0).

That would be a problem, since NaN compared to any ulp value would be false, but it doesn't look like it can happen

Problem occur when you test your code with some kind of sanitizers, which check division by zero. So in current code realization sanitizer fails even in correct data because of division. If I understood you right, your suggestion is to use isnan or something like that, but it will not help to solve our problem.

@tjulyz
Copy link

tjulyz commented Jan 11, 2024

Hi!
I also encountered this problem - "divide by zero".
temp = (this->fpv_ * this->re_ + that.fpv_ * that.re_) / fpv;
I have not found why fpv will be zero in some of condition. If fpv could be zero, how can we fix it?

@eadf
Copy link

eadf commented Jan 13, 2024

@tjulyz

Hi! I also encountered this problem - "divide by zero". temp = (this->fpv_ * this->re_ + that.fpv_ * that.re_) / fpv; I have not found why fpv will be zero in some of condition. If fpv could be zero, how can we fix it?

Do you have any sample data that generates the fault? That would be really helpful for tracking down the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants