fmt inf float str as "Inf"/"-Inf"

This commit is contained in:
jachewz
2025-04-08 23:23:08 +10:00
parent f7de575873
commit 12ae07874e
2 changed files with 14 additions and 0 deletions

View File

@@ -197,6 +197,12 @@ impl Display for OwnedValue {
} }
Self::Float(fl) => { Self::Float(fl) => {
let fl = *fl; let fl = *fl;
if fl == f64::INFINITY {
return write!(f, "Inf");
}
if fl == f64::NEG_INFINITY {
return write!(f, "-Inf");
}
if fl.is_nan() { if fl.is_nan() {
return write!(f, ""); return write!(f, "");
} }

View File

@@ -166,6 +166,14 @@ do_execsql_test select-like-expression {
select 2 % 0.5 select 2 % 0.5
} {} } {}
do_execsql_test select_positive_infinite_float {
SELECT 1.7976931348623157E+308 + 1e308; -- f64::MAX + 1e308
} {Inf}
do_execsql_test select_negative_infinite_float {
SELECT -1.7976931348623157E+308 - 1e308 -- f64::MIN - 1e308
} {-Inf}
do_execsql_test select_shl_large_negative_float { do_execsql_test select_shl_large_negative_float {
SELECT 1 << -1e19; SELECT 1 << -1e19;
SELECT 1 << -9223372036854775808; -- i64::MIN SELECT 1 << -9223372036854775808; -- i64::MIN