tilde vs floor
JavaScript performance comparison
Info
Comparison between ~~ and Math.floor
Preparation code
<script>
var x = 3.14;
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
tildes |
|
pending… |
floor |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Göran Andersson
- Revision 2: published by download
- Revision 3: published by Eric
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 8: published
- Revision 9: published by Austin
1 comment
It's worth noting that the functions don't do the same thing.
Math.floor(5.5) == ~~5.5 5 == 5
Math.floor(-5.5) != ~~-5.5 -6 != -5