LibJS: Implement Infinity

This commit is contained in:
Linus Groh 2020-04-02 16:59:01 +01:00 committed by Andreas Kling
commit 543c6e00db
Notes: sideshowbarker 2024-07-19 07:59:06 +09:00
5 changed files with 40 additions and 0 deletions

View file

@ -57,6 +57,9 @@ String Value::to_string() const
if (is_nan())
return "NaN";
if (is_infinity())
return as_double() < 0 ? "-Infinity" : "Infinity";
// FIXME: This needs improvement.
if ((double)to_i32() == as_double())
return String::number(to_i32());