Anyway, here is my minifier for JavaScript numeric literals, I hope it is of use to youhttps://github.com/ferno/minify-numeric-literal …
-
-
Replying to @qntm
My module shortens "1.476925632985436e99" by 1 character to "1476925632985436e84", eat that, UglifyJS
1 reply 0 retweets 7 likes -
Replying to @qntm
UglifyJS's approach is a little mystifying. "Maybe the octal representation is shorter!" https://github.com/mishoo/UglifyJS2/blob/569c21e952c99340db73d6ad1c7102500cc1b341/lib/output.js#L1312 …
1 reply 1 retweet 4 likes -
Replying to @qntm
Whether the hex representation is shorter than the decimal changes several times as numbers get bigger http://stackoverflow.com/questions/9458614/at-what-point-do-hexadecimal-representations-of-numbers-take-up-less-chars-than …
1 reply 1 retweet 3 likes -
Replying to @qntm
Additionally, there's an incredibly small number of cases where `0xfff...f` represents the same float as `0x1000...0` but saves a character
1 reply 0 retweets 2 likes -
Replying to @qntm
The same is true in base 10 (i.e. `999...9` represents the same float as `1000...0` but saves a character) but by then you're using `1e21`
1 reply 0 retweets 2 likes -
Replying to @qntm
Handling numbers in general, not just numeric literals, has far more pitfalls and potential for optimisation
1 reply 0 retweets 2 likes -
Replying to @qntm
An earlier version of UglifyJS naively replaced `Infinity` with `1/0`, but that turned e.g. `x/Infinity` into `x/1/0`
1 reply 0 retweets 2 likes -
Replying to @qntm
It also replaced `NaN` with `0/0`, turning `x/NaN` (always `NaN`) into `x/0/0` (`Infinity`, `-Infinity`, `NaN`) and SAVING NO CHARACTERS
2 replies 0 retweets 3 likes -
Replying to @qntm
`1<<17` is shorter than `131072`. `~99` is shorter than `-100`. `1e9-7` is shorter than `999999993`. But when is such a substitution safe?
3 replies 0 retweets 2 likes
And it turns out the number crunching to determine the shortest possible expression of an arbitrary float is deep and complicated
-
-
Replying to @qntm
`.1+.2` is shorter than `0.30000000000000004` but, starting from the latter, how in the WORLD would you get the former?
2 replies 0 retweets 3 likes -
Replying to @qntm
This seems to be a pretty challenging problem even if you assume no usage or declaration of functions in the available space
1 reply 0 retweets 1 like - 4 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.