OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 assertEquals(20480, toInt32(base + 21223)); | 106 assertEquals(20480, toInt32(base + 21223)); |
107 assertEquals(20480, toInt32(base + 22340)); | 107 assertEquals(20480, toInt32(base + 22340)); |
108 assertEquals(24576, toInt32(base + 23457)); | 108 assertEquals(24576, toInt32(base + 23457)); |
109 assertEquals(24576, toInt32(base + 24574)); | 109 assertEquals(24576, toInt32(base + 24574)); |
110 assertEquals(24576, toInt32(base + 25691)); | 110 assertEquals(24576, toInt32(base + 25691)); |
111 assertEquals(28672, toInt32(base + 26808)); | 111 assertEquals(28672, toInt32(base + 26808)); |
112 assertEquals(28672, toInt32(base + 27925)); | 112 assertEquals(28672, toInt32(base + 27925)); |
113 assertEquals(28672, toInt32(base + 29042)); | 113 assertEquals(28672, toInt32(base + 29042)); |
114 assertEquals(28672, toInt32(base + 30159)); | 114 assertEquals(28672, toInt32(base + 30159)); |
115 assertEquals(32768, toInt32(base + 31276)); | 115 assertEquals(32768, toInt32(base + 31276)); |
| 116 |
| 117 // bignum is (2^53 - 1) * 2^31 - highest number with bit 31 set. |
| 118 var bignum = Math.pow(2, 84) - Math.pow(2, 31); |
| 119 assertEquals(-Math.pow(2,31), toInt32(bignum)); |
| 120 assertEquals(-Math.pow(2,31), toInt32(-bignum)); |
| 121 assertEquals(0, toInt32(2 * bignum)); |
| 122 assertEquals(0, toInt32(-(2 * bignum))); |
| 123 assertEquals(0, toInt32(bignum - Math.pow(2,31))); |
| 124 assertEquals(0, toInt32(-(bignum - Math.pow(2,31)))); |
| 125 |
| 126 // max_fraction is largest number below 1. |
| 127 var max_fraction = (1 - Math.pow(2,-53)); |
| 128 assertEquals(0, toInt32(max_fraction)); |
| 129 assertEquals(0, toInt32(-max_fraction)); |
OLD | NEW |