Casting Float64 to Float16 rounds twice through f32
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 20/100
Hướng nghiên cứu
Start at arrow_cast::cast and trace the Float64 to Float16 path through num_cast and the half crate conversion described in the issue. The reproduction gives a precise failing value and expected result; use it to check the conversion path and add a regression test alongside the existing cast tests. Done means the value rounds to 1.0009766 directly from f64; issue #12476 already has an open pull request.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
cast from Float64 to Float16 goes through num_cast, and the half crate's NumCast for f16 converts with to_f32().map(f16::from_f32). That rounds to f32 first and then to f16. A value just above an f16 midpoint can land exactly on the midpoint in f32, and round-half-even then picks the lower neighbour.
To Reproduce
use arrow_array::{Float64Array, cast::AsArray, types::Float16Type};
use arrow_cast::cast;
use arrow_schema::DataType;
let x = 1.0 + 2f64.powi(-11) + 2f64.powi(-40);
let out = cast(&Float64Array::from(vec![x]), &DataType::Float16).unwrap();
println!("{}", out.as_primitive::<Float16Type>().value(0)); // 1
Expected behavior
The nearest f16, 1.0009766 (1 + 2^-10). x is above 1 + 2^-11, the midpoint between 1.0 and 1 + 2^-10, so it should round up.
Additional context
Switching to f16::from_f64 is not enough on its own: on x86 with F16C, half also implements it as f64 as f32 followed by the hardware f32 to f16 conversion, so it rounds twice there too.
Integer casts to Float16 also go through f32, but they are not affected: every integer in f16's range is exact in f32.
Willingness to contribute
I plan to contribute a fix for this bug independently
- Ngôn ngữ chính
- Rust
- Star
- 3.7k
- Fork
- 1.5k
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 183
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/arrow-rs
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`RunArray::try_new` rejects run ends whose null buffer has no nullsCó thể đã có người làm @Surajsuthar đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/arrow-rs#12427 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Variant] `variant_get` string and binary cast errors show Rust builder type namesCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/arrow-rs
Issue tương tự
-
area:ui effort:medium enhancement P7 source:agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
marketing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousĐang mởmaintainer-needed p2 remote triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug help wanted ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
userFRM/egui-charts#4605 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày