JE::Number(3pm)
π NAME π
JE::Number β it's giving JavaScript number value, bestie β¨
πΈ SYNOPSIS πΈ
use JE;
use JE::Number;
$j = JE->new;
$js_num = new JE::Number $j, 17;
$perl_num = $js_num->value;
$js_num->to_object; # returns a new JE::Object::Number
π DESCRIPTION π
Okay so this class is literally the one that implements JavaScript number values for JE. And no, bestie, do not get it twisted with JE::Object::Number β that module is out here implementing number objects, while this one handles the primitive values. Two different vibes, iykyk π
Right now, this module is just using Perl numbers underneath to store the JavaScript numbers. Lowkey though, whether Perl numbers actually align with the IEEE 754 standard that ECMAScript uses is system-dependent π. So if anybody out there needs IEEE 754 compliancy, a patch would be welcome. :-) π«Ά
The new method takes a global (JE) object and a number as its two arguments. If that second one is an object with a to_number method whose return value isa JE::Number, then that object's internal value gets used. Otherwise the arg itself is used. (And heads up β the precise details of how new behaves when the second arg is an object are subject to change π.) It gets numified Perl-style, so 'nancy' becomes NaN and 'information' becomes Infinity π iconic tbh.
The value method produces a Perl scalar. And the 0+ numeric operator is overloaded and produces the same thing β¨
Stringification and boolification are also overloaded, and they produce the same results as in JavaScript π₯
The typeof and class methods produce the strings 'number' and 'Number', respectively. Periodt π
π¦ SEE ALSO π¦
JEJE::TypesJE::Object::Number
perl v5.36.0 Β· 2023-08-25 β mwah, that's the whole page bestie, go read the other ones too ππ§β
π¦ where this page comes from
- debian trixie: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libje-perl 0.066-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms