-
Notifications
You must be signed in to change notification settings - Fork 13
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
Number encoding #9
Comments
It may be an idea to write -999999 as -1000000+1, and 1e12+1 to 1e12+1 but I don't know whether it's easy or difficult to achieve |
1.0000000000001e+113 |
-999999 can be written as -1000000 + 1 and 1e12+1 as 1e12+1, that's fine because those are integers between I'm not sure about 1.0000000000001e+113: this is a floating-point number that is only approximately equal to the sum of two powers of 10. Nothing in ECMAScript or IEEE-754 says that it couldn't be rounded to something slightly larger or slightly smaller, but most of all I don't know how consistent different engines are when calculating the sum of non-safe integers. JScrewIt must work with many different engines and I wouldn't be surprised if something that gives 1.000...0001 in my browser gave 1 in another one's browser. |
JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard. This format stores numbers in 64 bits, where the number (the fraction) is stored in bits 0 to 51, the exponent in bits 52 to 62, and the sign in bit 63: Value (aka Fraction/Mantissa) Exponent Sign Example |
The expression is not |
@837951602 Ah, I see. But why not |
Yes |
|
Not sure about if float values or exceeded_safe_integer calculated get the same value? If so, 0.9999999999999998(822c) can't be +('.'+(1e16-2))(323c) or 1-2e-16(339c) but only +('.'+(1e15-1)+8)(358c) |
So why is '-' translated into "1e-10"[2] instead of "1e-7"[2]? If because of compatible why no this feature |
1e-100 208c |
I don't know why "-" is defined how it is! This should be analyzed ASAP. |
(ECMA-262 5th edition December 2009, P48)
|
aemkei's jsfuck main page also said "0.0000001"->'1e-7' and get '-'. but creating it's 1e-10 |
Made a branch to test the "-" optimization: https://github.com/fasttime/JScrewIt/tree/minus-sign. Looks good so far. @837951602 Kudos for spotting this! |
|
There should only beXXXeYYY
and(AAA)(.BBB)
-- since point costs 72 chars far larger than '9' 47, it's never cheap to use both.With x being a positive finite number, turning x to XXXeYYY style uses
x.toExponential().replace(/^(\d)\.?(\d*)e(.*)$/,function(x,a,b,c){return a+b+'e'+(c-b.length)})
and to (AAA)(.BBB) useNumber.prototype.forceFixed=function(){var t=this.toString().split('e');if(t.length==1)return t.replace(/^0/,'');t[0]=t[0].replace(/\./,'');return t[1]>0?t[0]+Array(2- -t[1]-t[0].length).join(0):'.'+Array(-t[1]).join('0')+t[0]}
? (code not tested fully)The text was updated successfully, but these errors were encountered: