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

Make .inf and .sup const #88

Open
Chris00 opened this issue Feb 17, 2023 · 2 comments
Open

Make .inf and .sup const #88

Chris00 opened this issue Feb 17, 2023 · 2 comments

Comments

@Chris00
Copy link
Contributor

Chris00 commented Feb 17, 2023

Wouldn't it be desirable for the methods .inf() and .sup() to be constant? That would allow, for example, const_interval!(0., Interval::PI.sup()).

@unageek
Copy link
Owner

unageek commented Feb 18, 2023

Sure, but if I try making them const, I get the following errors at the moment.

error[E0658]: floating point arithmetic is not allowed in constant functions
  --> src/interval.rs:67:9
   |
67 |         -extract0(self.rep)
   |         ^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information

error: `core::f64::<impl f64>::is_nan` is not yet stable as a const fn
  --> src/numeric.rs:29:12
   |
29 |         if x.is_nan() {
   |            ^^^^^^^^^^

error[E0658]: floating point arithmetic is not allowed in constant functions
  --> src/numeric.rs:32:19
   |
32 |         } else if x == 0.0 {
   |                   ^^^^^^^^
   |
   = note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information

error: `core::f64::<impl f64>::is_nan` is not yet stable as a const fn
   --> src/numeric.rs:206:12
    |
206 |         if x.is_nan() {
    |            ^^^^^^^^^^

error[E0658]: floating point arithmetic is not allowed in constant functions
   --> src/numeric.rs:209:19
    |
209 |         } else if x == 0.0 {
    |                   ^^^^^^^^
    |
    = note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information

@Chris00
Copy link
Contributor Author

Chris00 commented Feb 18, 2023

Ah, indeed, I hadn't tried. We'll have to wait that they stabilize the feature further...

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

2 participants