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

f16::ZERO and f16::ONE are mixed up #4016

Closed
izveigor opened this issue Apr 4, 2023 · 1 comment · Fixed by #4017
Closed

f16::ZERO and f16::ONE are mixed up #4016

izveigor opened this issue Apr 4, 2023 · 1 comment · Fixed by #4017
Labels
arrow Changes to the arrow crate bug

Comments

@izveigor
Copy link
Contributor

izveigor commented Apr 4, 2023

Describe the bug
DivideByZero occurs when div_checked and mod_checked are called with the argument f16::ONE.

To Reproduce

use half::f16;
use arrow::array::Float16Array;
use arrow::datatypes::ArrowNativeTypeOp;

fn main() {
    let arr: Float16Array = [Some(f16::from_f64(1.0)), Some(f16::from_f64(2.0))].into_iter().collect();
    println!("{:#?}", arr);
    println!("{:#?}", arr.value(0).div_checked(f16::ONE));
    println!("{:#?}", arr.value(0).mod_checked(f16::ONE));
}

output:

PrimitiveArray<Float16>
[
  1.0,
  2.0,
]
Err(
    DivideByZero,
)
Err(
    DivideByZero,
)

Expected behavior
output:

PrimitiveArray<Float16>
[
  1.0,
  2.0,
]
1.0
0.0

Additional context

@izveigor izveigor added the bug label Apr 4, 2023
@tustvold tustvold added the arrow Changes to the arrow crate label Apr 7, 2023
@tustvold
Copy link
Contributor

tustvold commented Apr 7, 2023

label_issue.py automatically added labels {'arrow'} from #4017

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

Successfully merging a pull request may close this issue.

2 participants