| | 1 | #include "tads.h" |
| | 2 | #include "t3.h" |
| | 3 | #include "bignum.h" |
| | 4 | |
| | 5 | main(args) |
| | 6 | { |
| | 7 | local x, y, z, lst; |
| | 8 | |
| | 9 | /* |
| | 10 | * creation tests |
| | 11 | */ |
| | 12 | x = new BigNumber('3.1415927'); |
| | 13 | y = new BigNumber('1234567890987654321'); |
| | 14 | y = new BigNumber('12345678909876543210'); |
| | 15 | y = new BigNumber(100, 10); |
| | 16 | y = new BigNumber(12345, 32); |
| | 17 | y = new BigNumber(123456, 33); |
| | 18 | |
| | 19 | /* |
| | 20 | * display tests |
| | 21 | */ |
| | 22 | tadsSay(new BigNumber('1234.5678')); "\n"; |
| | 23 | tadsSay(x); "\n"; |
| | 24 | tadsSay(y); "\n"; |
| | 25 | tadsSay(new BigNumber('123456789234567893456789456789567896789789899')); "\n"; |
| | 26 | tadsSay(new BigNumber('100e-2000')); "\n"; |
| | 27 | tadsSay(new BigNumber('5.9999988888e5000')); "\n"; |
| | 28 | tadsSay(new BigNumber('12345e-20000')); "\n"; |
| | 29 | tadsSay(new BigNumber('1234e-8')); "\n"; |
| | 30 | tadsSay(new BigNumber('.090807')); "\n"; |
| | 31 | "\b"; |
| | 32 | |
| | 33 | /* |
| | 34 | * string formatting tests |
| | 35 | */ |
| | 36 | |
| | 37 | x = toString(new BigNumber('.75e4')); |
| | 38 | tadsSay(x); "\n"; |
| | 39 | "\b"; |
| | 40 | |
| | 41 | x = new BigNumber('1234.5362'); |
| | 42 | "(4): <<x.formatString(4)>>\n"; |
| | 43 | "(5): <<x.formatString(5)>>\n"; |
| | 44 | "(6): <<x.formatString(6)>>\n"; |
| | 45 | "(7): <<x.formatString(7)>>\n"; |
| | 46 | "\b"; |
| | 47 | |
| | 48 | x = new BigNumber('999.99999'); |
| | 49 | "(8): <<x.formatString(8)>>\n"; |
| | 50 | "(7): <<x.formatString(7)>>\n"; |
| | 51 | "(5): <<x.formatString(5)>>\n"; |
| | 52 | "(4): <<x.formatString(4)>>\n"; |
| | 53 | "(3): <<x.formatString(3)>>\n"; |
| | 54 | "(2): <<x.formatString(2)>>\n"; |
| | 55 | "(7,0,0,3): <<x.formatString(7, 0, 0, 3)>>\n"; |
| | 56 | "(7,0,0,5): <<x.formatString(7, 0, 0, 5)>>\n"; |
| | 57 | "(8,EXP): <<x.formatString(8, BignumExp)>>\n"; |
| | 58 | "(7,EXP): <<x.formatString(7, BignumExp)>>\n"; |
| | 59 | "(3,EXP+PT): <<x.formatString(3, BignumExp | BignumPoint)>>\n"; |
| | 60 | "(8,EXP,0,2): <<x.formatString(8, BignumExp, 0, 2)>>\n"; |
| | 61 | "(10,0,7,5): <<x.formatString(10, 0, 7, 5)>>\n"; |
| | 62 | "(10,0,7,3): <<x.formatString(10, 0, 7, 3)>>\n"; |
| | 63 | |
| | 64 | "(15,0,12,3,0,'*'): <<x.formatString(15, 0, 12, 3, 0, '*')>>\n"; |
| | 65 | "(15,0,12,3,0,'/*\\*'): <<x.formatString(15, 0, 12, 3, 0, '/*\\*')>>\n"; |
| | 66 | "(15,COMMAS,12,3,0,'/*\\*'): |
| | 67 | <<x.formatString(15, BignumCommas, 12, 3, 0, '/*\\*')>>\n"; |
| | 68 | |
| | 69 | x = new BigNumber('12345.6789'); |
| | 70 | "(15,COMMAS,12,3,0,'/*\\*'): |
| | 71 | <<x.formatString(15, BignumCommas, 12, 3, 0, '/*\\*')>>\n"; |
| | 72 | |
| | 73 | x = new BigNumber('1234567.8900'); |
| | 74 | "(15,COMMAS,12,3,0,'/*\\*'): |
| | 75 | <<x.formatString(15, BignumCommas, 12, 3, 0, '/*\\*')>>\n"; |
| | 76 | |
| | 77 | x = new BigNumber('12345678.8900'); |
| | 78 | "(15,COMMAS,12,3,0,'/*\\*'): |
| | 79 | <<x.formatString(15, BignumCommas, 12, 3, 0, '/*\\*')>>\n"; |
| | 80 | |
| | 81 | x = new BigNumber('12345678.98765'); |
| | 82 | "(20,COMMAS): <<x.formatString(20, BignumCommas)>>\n"; |
| | 83 | "(20,COMMAS+EURO): |
| | 84 | <<x.formatString(20, BignumCommas | BignumEuroStyle)>>\n"; |
| | 85 | "(20 - no space):<<x.formatString(20)>>\n"; |
| | 86 | "(20,POS_SPACE):<<x.formatString(20, BignumPosSpace)>>\n"; |
| | 87 | |
| | 88 | x = new BigNumber('123456789.98765'); |
| | 89 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 90 | |
| | 91 | x = new BigNumber('.00098765'); |
| | 92 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 93 | x = new BigNumber('0.98765'); |
| | 94 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 95 | x = new BigNumber('1.98765'); |
| | 96 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 97 | x = new BigNumber('12.98765'); |
| | 98 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 99 | x = new BigNumber('123.98765'); |
| | 100 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 101 | x = new BigNumber('1234.98765'); |
| | 102 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 103 | x = new BigNumber('12345.98765'); |
| | 104 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 105 | x = new BigNumber('123456.98765'); |
| | 106 | "(20,COMMAS):<<x.formatString(20, BignumCommas)>>\n"; |
| | 107 | "\b"; |
| | 108 | |
| | 109 | /* |
| | 110 | * Zero formatting tests |
| | 111 | */ |
| | 112 | |
| | 113 | x = new BigNumber('0'); |
| | 114 | "zero: <<x>>\n"; |
| | 115 | "(3,EXP): <<x.formatString(3, BignumExp)>>\n"; |
| | 116 | "(8,EXP+PT): <<x.formatString(8, BignumExp | BignumPoint)>>\n"; |
| | 117 | "(8,EXP,0,2): <<x.formatString(8, BignumExp, 0, 2)>>\n"; |
| | 118 | "\b"; |
| | 119 | |
| | 120 | /* |
| | 121 | * equality comparison tests |
| | 122 | */ |
| | 123 | |
| | 124 | x = new BigNumber('123.456'); |
| | 125 | y = new BigNumber('123.45600001'); |
| | 126 | "x = <<x>>, y = <<y>>\n"; |
| | 127 | "(equal exact): <<x == y ? 'yes' : 'no'>>\n"; |
| | 128 | "(equal with rounding): <<x.equalRound(y) ? 'yes' : 'no'>>\n"; |
| | 129 | |
| | 130 | x = new BigNumber('123.456'); |
| | 131 | y = new BigNumber('1.23456e2'); |
| | 132 | "x = <<x>>, y = <<y>>\n"; |
| | 133 | "(equal exact): <<x == y ? 'yes' : 'no'>>\n"; |
| | 134 | "(equal with rounding): <<x.equalRound(y) ? 'yes' : 'no'>>\n"; |
| | 135 | |
| | 136 | x = new BigNumber('100'); |
| | 137 | y = new BigNumber('99.999'); |
| | 138 | "x = <<x>>, y = <<y>>\n"; |
| | 139 | "(equal exact): <<x == y ? 'yes' : 'no'>>\n"; |
| | 140 | "(equal with rounding): <<x.equalRound(y) ? 'yes' : 'no'>>\n"; |
| | 141 | |
| | 142 | x = new BigNumber('100.001'); |
| | 143 | y = new BigNumber('100.002'); |
| | 144 | "x = <<x>>, y = <<y>>\n"; |
| | 145 | "(equal exact): <<x == y ? 'yes' : 'no'>>\n"; |
| | 146 | "(equal with rounding): <<x.equalRound(y) ? 'yes' : 'no'>>\n"; |
| | 147 | "\b"; |
| | 148 | |
| | 149 | /* |
| | 150 | * Magnitude comparison tests |
| | 151 | */ |
| | 152 | |
| | 153 | x = new BigNumber('123.456'); |
| | 154 | y = new BigNumber('123.4561'); |
| | 155 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 156 | |
| | 157 | x = new BigNumber('123.456'); |
| | 158 | y = new BigNumber('-123.4561'); |
| | 159 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 160 | |
| | 161 | x = new BigNumber('-123.4561'); |
| | 162 | y = new BigNumber('123.4560'); |
| | 163 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 164 | |
| | 165 | x = new BigNumber('-123.456'); |
| | 166 | y = new BigNumber('-123.4561'); |
| | 167 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 168 | |
| | 169 | x = new BigNumber('999'); |
| | 170 | y = new BigNumber('.999'); |
| | 171 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 172 | |
| | 173 | x = new BigNumber('-999'); |
| | 174 | y = new BigNumber('-.999'); |
| | 175 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 176 | |
| | 177 | x = new BigNumber('1'); |
| | 178 | y = new BigNumber('2'); |
| | 179 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 180 | |
| | 181 | x = new BigNumber('111.01'); |
| | 182 | y = new BigNumber('111.10'); |
| | 183 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 184 | |
| | 185 | x = new BigNumber('0.0000'); |
| | 186 | y = new BigNumber('35.3'); |
| | 187 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 188 | |
| | 189 | x = new BigNumber('-32.000'); |
| | 190 | y = new BigNumber('0.000'); |
| | 191 | "x = <<x>>, y = <<y>>, x < y = <<bool(x<y)>>, x > y = <<bool(x>y)>>\n"; |
| | 192 | |
| | 193 | "\b"; |
| | 194 | |
| | 195 | /* |
| | 196 | * Get/Set-Precision tests |
| | 197 | */ |
| | 198 | |
| | 199 | x = new BigNumber('1234567890'); |
| | 200 | "x = <<x>>, x.getPrecision() = <<x.getPrecision()>>, |
| | 201 | x.setPrecision(5) = <<x.setPrecision(5)>>, "; |
| | 202 | |
| | 203 | "x.setPrecision(3) = <<x.setPrecision(3)>>\n"; |
| | 204 | |
| | 205 | "x.setPrecision(15) = <<x.setPrecision(15)>>\n"; |
| | 206 | "\b"; |
| | 207 | |
| | 208 | /* |
| | 209 | * Addition and subtraction tests |
| | 210 | */ |
| | 211 | |
| | 212 | x = new BigNumber('12345.6789'); |
| | 213 | y = new BigNumber('3.14159265'); |
| | 214 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 215 | |
| | 216 | x = new BigNumber('1.999999'); |
| | 217 | y = new BigNumber('2.001'); |
| | 218 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 219 | |
| | 220 | x = new BigNumber('1200'); |
| | 221 | y = new BigNumber('.0533'); |
| | 222 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 223 | |
| | 224 | x = new BigNumber('1200'); |
| | 225 | y = new BigNumber('.5335'); |
| | 226 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 227 | |
| | 228 | x = new BigNumber('9999'); |
| | 229 | y = new BigNumber('.5335'); |
| | 230 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x+y+1 = <<x+y+1>>\n"; |
| | 231 | "x-y = <<x-y>>\n"; |
| | 232 | |
| | 233 | x = new BigNumber('9999'); |
| | 234 | y = new BigNumber('.4999'); |
| | 235 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x+y+1 = <<x+y+1>>\n"; |
| | 236 | "x-y = <<x-y>>\n"; |
| | 237 | |
| | 238 | x = new BigNumber('9999'); |
| | 239 | y = new BigNumber('1.999'); |
| | 240 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 241 | |
| | 242 | x = new BigNumber('9999'); |
| | 243 | y = new BigNumber('9.999'); |
| | 244 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 245 | |
| | 246 | x = new BigNumber('9999'); |
| | 247 | y = new BigNumber('5.999'); |
| | 248 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 249 | |
| | 250 | x = new BigNumber('9999'); |
| | 251 | y = new BigNumber('6.999'); |
| | 252 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 253 | |
| | 254 | x = new BigNumber('9999'); |
| | 255 | y = new BigNumber('3.999'); |
| | 256 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 257 | |
| | 258 | x = new BigNumber('1234'); |
| | 259 | y = new BigNumber('-5678'); |
| | 260 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 261 | |
| | 262 | x = new BigNumber('-1234'); |
| | 263 | y = new BigNumber('5678'); |
| | 264 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 265 | |
| | 266 | x = new BigNumber('1000.1'); |
| | 267 | y = new BigNumber('.0001'); |
| | 268 | "x = <<x>>, y = <<y>>, x+y = <<x+y>>, x-y = <<x-y>>\n"; |
| | 269 | |
| | 270 | "\b"; |
| | 271 | |
| | 272 | /* |
| | 273 | * Multiplication |
| | 274 | */ |
| | 275 | x = new BigNumber('1'); |
| | 276 | y = new BigNumber('1.00001'); |
| | 277 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 278 | |
| | 279 | x = new BigNumber('3456'); |
| | 280 | y = new BigNumber('3'); |
| | 281 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 282 | |
| | 283 | x = new BigNumber('1234'); |
| | 284 | y = new BigNumber('5678'); |
| | 285 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 286 | |
| | 287 | x = new BigNumber('1.999'); |
| | 288 | y = new BigNumber('9.99'); |
| | 289 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 290 | |
| | 291 | x = new BigNumber('3.14159265'); |
| | 292 | y = new BigNumber('0.25'); |
| | 293 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 294 | |
| | 295 | x = new BigNumber('8751'); |
| | 296 | y = new BigNumber('1.1110000'); |
| | 297 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 298 | |
| | 299 | x = new BigNumber('8751'); |
| | 300 | y = new BigNumber('1.111'); |
| | 301 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 302 | |
| | 303 | x = new BigNumber('8751'); |
| | 304 | y = new BigNumber('9.0009'); |
| | 305 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 306 | |
| | 307 | x = new BigNumber('8751'); |
| | 308 | y = new BigNumber('9.000009'); |
| | 309 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 310 | |
| | 311 | x = new BigNumber('-3883.1'); |
| | 312 | y = new BigNumber('57.6010199'); |
| | 313 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 314 | |
| | 315 | x = new BigNumber('42.7'); |
| | 316 | y = new BigNumber('-177'); |
| | 317 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 318 | |
| | 319 | x = new BigNumber('-.979'); |
| | 320 | y = new BigNumber('-3.203'); |
| | 321 | "x = <<x>>, y = <<y>>, x*y = <<x*y>>\n"; |
| | 322 | |
| | 323 | "\b"; |
| | 324 | |
| | 325 | /* |
| | 326 | * Division |
| | 327 | */ |
| | 328 | |
| | 329 | x = new BigNumber('-.979'); |
| | 330 | y = new BigNumber('-3.203'); |
| | 331 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 332 | |
| | 333 | x = new BigNumber('32'); |
| | 334 | y = new BigNumber('522'); |
| | 335 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 336 | |
| | 337 | x = new BigNumber('7205'); |
| | 338 | y = new BigNumber('3'); |
| | 339 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 340 | |
| | 341 | x = new BigNumber('1'); |
| | 342 | y = new BigNumber('1.00001'); |
| | 343 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 344 | |
| | 345 | x = new BigNumber('3456'); |
| | 346 | y = new BigNumber('3'); |
| | 347 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 348 | |
| | 349 | x = new BigNumber('1234'); |
| | 350 | y = new BigNumber('5678'); |
| | 351 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 352 | |
| | 353 | x = new BigNumber('1.999'); |
| | 354 | y = new BigNumber('9.99'); |
| | 355 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 356 | |
| | 357 | x = new BigNumber('3.14159265'); |
| | 358 | y = new BigNumber('0.25'); |
| | 359 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 360 | |
| | 361 | x = new BigNumber('8751'); |
| | 362 | y = new BigNumber('1.1110000'); |
| | 363 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 364 | |
| | 365 | x = new BigNumber('8751'); |
| | 366 | y = new BigNumber('1.111'); |
| | 367 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 368 | |
| | 369 | x = new BigNumber('8751'); |
| | 370 | y = new BigNumber('9.0009'); |
| | 371 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 372 | |
| | 373 | x = new BigNumber('8751'); |
| | 374 | y = new BigNumber('9.000009'); |
| | 375 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 376 | |
| | 377 | x = new BigNumber('-3883.1'); |
| | 378 | y = new BigNumber('57.6010199'); |
| | 379 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 380 | |
| | 381 | x = new BigNumber('42.7'); |
| | 382 | y = new BigNumber('-177'); |
| | 383 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 384 | |
| | 385 | x = new BigNumber('-.979'); |
| | 386 | y = new BigNumber('-3.203'); |
| | 387 | "x = <<x>>, y = <<y>>, x/y = <<x/y>>\n"; |
| | 388 | |
| | 389 | /* |
| | 390 | * Remainders |
| | 391 | */ |
| | 392 | |
| | 393 | x = new BigNumber('12345'); |
| | 394 | y = new BigNumber('77'); |
| | 395 | lst = x.divideBy(y); |
| | 396 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 397 | |
| | 398 | x = new BigNumber('12397'); |
| | 399 | y = new BigNumber('77'); |
| | 400 | lst = x.divideBy(y); |
| | 401 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 402 | |
| | 403 | x = new BigNumber('12396'); |
| | 404 | y = new BigNumber('77'); |
| | 405 | lst = x.divideBy(y); |
| | 406 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 407 | |
| | 408 | x = new BigNumber('77'); |
| | 409 | y = new BigNumber('123'); |
| | 410 | lst = x.divideBy(y); |
| | 411 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 412 | |
| | 413 | x = new BigNumber('-12345'); |
| | 414 | y = new BigNumber('77'); |
| | 415 | lst = x.divideBy(y); |
| | 416 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 417 | |
| | 418 | x = new BigNumber('12345'); |
| | 419 | y = new BigNumber('-77'); |
| | 420 | lst = x.divideBy(y); |
| | 421 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 422 | |
| | 423 | x = new BigNumber('-12345'); |
| | 424 | y = new BigNumber('-77'); |
| | 425 | lst = x.divideBy(y); |
| | 426 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 427 | |
| | 428 | x = new BigNumber('-10'); |
| | 429 | y = new BigNumber('-3'); |
| | 430 | lst = x.divideBy(y); |
| | 431 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 432 | |
| | 433 | x = new BigNumber('123e5'); |
| | 434 | y = new BigNumber('77'); |
| | 435 | lst = x.divideBy(y); |
| | 436 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 437 | |
| | 438 | x = new BigNumber('0.000'); |
| | 439 | y = new BigNumber('77'); |
| | 440 | lst = x.divideBy(y); |
| | 441 | "x = <<x>>, y = <<y>>, x/y = <<lst[1]>>, x mod y = <<lst[2]>>\n"; |
| | 442 | |
| | 443 | "\b"; |
| | 444 | |
| | 445 | /* |
| | 446 | * Fraction/Whole tests |
| | 447 | */ |
| | 448 | |
| | 449 | x = new BigNumber('1234.5678'); |
| | 450 | "x = <<x>>, frac = <<x.getFraction()>>, whole = <<x.getWhole()>>\n"; |
| | 451 | |
| | 452 | x = new BigNumber('.9325773'); |
| | 453 | "x = <<x>>, frac = <<x.getFraction()>>, whole = <<x.getWhole()>>\n"; |
| | 454 | |
| | 455 | x = new BigNumber('8.710243'); |
| | 456 | "x = <<x>>, frac = <<x.getFraction()>>, whole = <<x.getWhole()>>\n"; |
| | 457 | |
| | 458 | x = new BigNumber('1.234e-15'); |
| | 459 | "x = <<x>>, frac = <<x.getFraction()>>, whole = <<x.getWhole()>>\n"; |
| | 460 | |
| | 461 | x = new BigNumber('1234567800000000'); |
| | 462 | "x = <<x>>, frac = <<x.getFraction()>>, whole = <<x.getWhole()>>\n"; |
| | 463 | |
| | 464 | "\b"; |
| | 465 | |
| | 466 | /* |
| | 467 | * RoundToDecimal tests |
| | 468 | */ |
| | 469 | |
| | 470 | x = new BigNumber('1234.53739'); |
| | 471 | "x = <<x>>, round(0) = <<x.roundToDecimal(0)>>\n |
| | 472 | ... round(1) = <<x.roundToDecimal(1)>>\n |
| | 473 | ... round(2) = <<x.roundToDecimal(2)>>\n |
| | 474 | ... round(3) = <<x.roundToDecimal(3)>>\n |
| | 475 | ... round(4) = <<x.roundToDecimal(4)>>\n |
| | 476 | ... round(5) = <<x.roundToDecimal(5)>>\n |
| | 477 | ... round(6) = <<x.roundToDecimal(6)>>\n |
| | 478 | ... round(7) = <<x.roundToDecimal(7)>>\n |
| | 479 | ... round(22) = <<x.roundToDecimal(22)>>\n |
| | 480 | ... round(-1) = <<x.roundToDecimal(-1)>>\n |
| | 481 | ... round(-2) = <<x.roundToDecimal(-2)>>\n |
| | 482 | ... round(-3) = <<x.roundToDecimal(-3)>>\n |
| | 483 | ... round(-4) = <<x.roundToDecimal(-4)>>\n |
| | 484 | ... round(-5) = <<x.roundToDecimal(-5)>>\n |
| | 485 | ... round(-10) = <<x.roundToDecimal(-10)>>\n"; |
| | 486 | x = new BigNumber('9999.99999'); |
| | 487 | "x = <<x>>, round(0) = <<x.roundToDecimal(0)>>\n |
| | 488 | ... round(1) = <<x.roundToDecimal(1)>>\n |
| | 489 | ... round(2) = <<x.roundToDecimal(2)>>\n |
| | 490 | ... round(3) = <<x.roundToDecimal(3)>>\n |
| | 491 | ... round(4) = <<x.roundToDecimal(4)>>\n |
| | 492 | ... round(5) = <<x.roundToDecimal(5)>>\n |
| | 493 | ... round(6) = <<x.roundToDecimal(6)>>\n |
| | 494 | ... round(7) = <<x.roundToDecimal(7)>>\n |
| | 495 | ... round(22) = <<x.roundToDecimal(22)>>\n |
| | 496 | ... round(-1) = <<x.roundToDecimal(-1)>>\n |
| | 497 | ... round(-2) = <<x.roundToDecimal(-2)>>\n |
| | 498 | ... round(-3) = <<x.roundToDecimal(-3)>>\n |
| | 499 | ... round(-4) = <<x.roundToDecimal(-4)>>\n |
| | 500 | ... round(-5) = <<x.roundToDecimal(-5)>>\n |
| | 501 | ... round(-10) = <<x.roundToDecimal(-10)>>\n"; |
| | 502 | |
| | 503 | "\b"; |
| | 504 | |
| | 505 | /* |
| | 506 | * abs, floor, ceil tests |
| | 507 | */ |
| | 508 | x = new BigNumber('0.1234'); |
| | 509 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 510 | floor(x) = <<x.getFloor()>>\n"; |
| | 511 | |
| | 512 | x = new BigNumber('-0.1234'); |
| | 513 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 514 | floor(x) = <<x.getFloor()>>\n"; |
| | 515 | |
| | 516 | x = new BigNumber('7.1234'); |
| | 517 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 518 | floor(x) = <<x.getFloor()>>\n"; |
| | 519 | |
| | 520 | x = new BigNumber('-7.1234'); |
| | 521 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 522 | floor(x) = <<x.getFloor()>>\n"; |
| | 523 | |
| | 524 | x = new BigNumber('0.0000'); |
| | 525 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 526 | floor(x) = <<x.getFloor()>>\n"; |
| | 527 | |
| | 528 | x = new BigNumber('1.4e-5'); |
| | 529 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 530 | floor(x) = <<x.getFloor()>>\n"; |
| | 531 | |
| | 532 | x = new BigNumber('-1.4e-5'); |
| | 533 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 534 | floor(x) = <<x.getFloor()>>\n"; |
| | 535 | |
| | 536 | x = new BigNumber('999.9999'); |
| | 537 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 538 | floor(x) = <<x.getFloor()>>\n"; |
| | 539 | |
| | 540 | x = new BigNumber('-999.9999'); |
| | 541 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 542 | floor(x) = <<x.getFloor()>>\n"; |
| | 543 | |
| | 544 | x = new BigNumber('999.0000000001'); |
| | 545 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 546 | floor(x) = <<x.getFloor()>>\n"; |
| | 547 | |
| | 548 | x = new BigNumber('-999.0000000001'); |
| | 549 | "x = <<x>>, abs(x) = <<x.getAbs()>>, ceil(x) = <<x.getCeil()>>, |
| | 550 | floor(x) = <<x.getFloor()>>\n"; |
| | 551 | |
| | 552 | "\b"; |
| | 553 | |
| | 554 | /* |
| | 555 | * scaleTen tets |
| | 556 | */ |
| | 557 | |
| | 558 | x = new BigNumber('12345'); |
| | 559 | for (local i = -5 ; i <= 5 ; ++i) |
| | 560 | "x = <<x>>, x.scaleTen(<<i>>) = <<x.scaleTen(i)>>\n"; |
| | 561 | |
| | 562 | "x.getScale() = <<x.getScale()>>\n"; |
| | 563 | for (local i = -5 ; i <= 5 ; ++i) |
| | 564 | "x.scaleTen(<<i>>).getScale() = <<x.scaleTen(i).getScale()>>\n"; |
| | 565 | |
| | 566 | "\b"; |
| | 567 | |
| | 568 | /* |
| | 569 | * negate tests |
| | 570 | */ |
| | 571 | x = new BigNumber('0'); |
| | 572 | "x = <<x>>, x.negate() = <<x.negate()>>\n"; |
| | 573 | |
| | 574 | x = new BigNumber('123'); |
| | 575 | "x = <<x>>, x.negate() = <<x.negate()>>\n"; |
| | 576 | |
| | 577 | x = new BigNumber('0.123'); |
| | 578 | "x = <<x>>, x.negate() = <<x.negate()>>\n"; |
| | 579 | |
| | 580 | x = new BigNumber('-0.123'); |
| | 581 | "x = <<x>>, x.negate() = <<x.negate()>>\n"; |
| | 582 | |
| | 583 | x = new BigNumber('-987'); |
| | 584 | "x = <<x>>, x.negate() = <<x.negate()>>\n"; |
| | 585 | |
| | 586 | x = new BigNumber('-987'); |
| | 587 | "x = <<x>>, -x = <<-x>>\n"; |
| | 588 | |
| | 589 | x = new BigNumber('123.456'); |
| | 590 | "x = <<x>>, -x = <<-x>>\n"; |
| | 591 | |
| | 592 | "\b"; |
| | 593 | |
| | 594 | /* |
| | 595 | * copySignFrom tests |
| | 596 | */ |
| | 597 | x = new BigNumber('123'); |
| | 598 | y = new BigNumber('.345'); |
| | 599 | "x = <<x>>, y = <<y>>, x.copySignFrom(y) = <<x.copySignFrom(y)>>\n"; |
| | 600 | |
| | 601 | x = new BigNumber('123'); |
| | 602 | y = new BigNumber('-.345'); |
| | 603 | "x = <<x>>, y = <<y>>, x.copySignFrom(y) = <<x.copySignFrom(y)>>\n"; |
| | 604 | |
| | 605 | x = new BigNumber('-123'); |
| | 606 | y = new BigNumber('.345'); |
| | 607 | "x = <<x>>, y = <<y>>, x.copySignFrom(y) = <<x.copySignFrom(y)>>\n"; |
| | 608 | |
| | 609 | x = new BigNumber('-123'); |
| | 610 | y = new BigNumber('-.345'); |
| | 611 | "x = <<x>>, y = <<y>>, x.copySignFrom(y) = <<x.copySignFrom(y)>>\n"; |
| | 612 | |
| | 613 | x = new BigNumber('0'); |
| | 614 | y = new BigNumber('.345'); |
| | 615 | "x = <<x>>, y = <<y>>, x.copySignFrom(y) = <<x.copySignFrom(y)>>\n"; |
| | 616 | |
| | 617 | x = new BigNumber('0'); |
| | 618 | y = new BigNumber('-3.345'); |
| | 619 | "x = <<x>>, y = <<y>>, x.copySignFrom(y) = <<x.copySignFrom(y)>>\n"; |
| | 620 | |
| | 621 | "\b"; |
| | 622 | |
| | 623 | /* |
| | 624 | * IsNegative tests |
| | 625 | */ |
| | 626 | |
| | 627 | x = new BigNumber('0'); |
| | 628 | "x = <<x>>, x.isNegative = <<x.isNegative() ? 'yes' : 'no'>>\n"; |
| | 629 | |
| | 630 | x = new BigNumber('123'); |
| | 631 | "x = <<x>>, x.isNegative = <<x.isNegative() ? 'yes' : 'no'>>\n"; |
| | 632 | |
| | 633 | x = new BigNumber('-123'); |
| | 634 | "x = <<x>>, x.isNegative = <<x.isNegative() ? 'yes' : 'no'>>\n"; |
| | 635 | |
| | 636 | x = new BigNumber('0.005'); |
| | 637 | "x = <<x>>, x.isNegative = <<x.isNegative() ? 'yes' : 'no'>>\n"; |
| | 638 | |
| | 639 | x = new BigNumber('-0.005'); |
| | 640 | "x = <<x>>, x.isNegative = <<x.isNegative() ? 'yes' : 'no'>>\n"; |
| | 641 | |
| | 642 | "\b"; |
| | 643 | |
| | 644 | /* |
| | 645 | * toInteger tests |
| | 646 | */ |
| | 647 | |
| | 648 | x = new BigNumber('0'); |
| | 649 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 650 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 651 | |
| | 652 | x = new BigNumber('123'); |
| | 653 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 654 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 655 | |
| | 656 | x = new BigNumber('0.456'); |
| | 657 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 658 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 659 | |
| | 660 | x = new BigNumber('0.567'); |
| | 661 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 662 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 663 | |
| | 664 | x = new BigNumber('987.568'); |
| | 665 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 666 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 667 | |
| | 668 | x = new BigNumber('893.499'); |
| | 669 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 670 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 671 | |
| | 672 | x = new BigNumber('2147483646.299'); |
| | 673 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 674 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 675 | |
| | 676 | x = new BigNumber('2147483646.832'); |
| | 677 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 678 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 679 | |
| | 680 | x = new BigNumber('2147483647.299'); |
| | 681 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 682 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 683 | |
| | 684 | x = new BigNumber('2147483647.832'); |
| | 685 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 686 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 687 | |
| | 688 | x = new BigNumber('-2147483647.200'); |
| | 689 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 690 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 691 | |
| | 692 | x = new BigNumber('-2147483647.822'); |
| | 693 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 694 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 695 | |
| | 696 | x = new BigNumber('-2147483648.200'); |
| | 697 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 698 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 699 | |
| | 700 | x = new BigNumber('-2147483648.822'); |
| | 701 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 702 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 703 | |
| | 704 | x = new BigNumber('9999999999.200'); |
| | 705 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 706 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 707 | |
| | 708 | x = new BigNumber('-9999999999.200'); |
| | 709 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 710 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 711 | |
| | 712 | x = new BigNumber('2149.7483647200'); |
| | 713 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 714 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 715 | |
| | 716 | x = new BigNumber('-2149.7483647200'); |
| | 717 | try { "x = <<x>>, toInteger(x) = <<toInteger(x)>>\n"; } |
| | 718 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 719 | |
| | 720 | "\b"; |
| | 721 | |
| | 722 | /* |
| | 723 | * Sine |
| | 724 | */ |
| | 725 | x = new BigNumber('0.785398164'); // pi/4 -> .707106782 |
| | 726 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 727 | |
| | 728 | x = new BigNumber('1.57079633'); // pi/2 -> 1.0000000 |
| | 729 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 730 | |
| | 731 | x = new BigNumber('3.14159265'); // pi -> 0 |
| | 732 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 733 | |
| | 734 | x = new BigNumber('1.11111'); // -> 0.896192 |
| | 735 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 736 | |
| | 737 | x = new BigNumber('2.0000'); // -> 0.909297 -> .90930 |
| | 738 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 739 | |
| | 740 | x = new BigNumber('3.010203'); // -> .1310119 |
| | 741 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 742 | |
| | 743 | x = new BigNumber('4.567890'); // -> -.9895782 |
| | 744 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 745 | |
| | 746 | x = new BigNumber('5.43210'); // -> -.751996 |
| | 747 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 748 | |
| | 749 | x = new BigNumber('6.012345'); // -> -.2675412 |
| | 750 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 751 | |
| | 752 | x = new BigNumber('6.305555'); // a little over 2pi -> .02236783 |
| | 753 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 754 | |
| | 755 | x = new BigNumber('9.350123'); // -> 0.07458563 |
| | 756 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 757 | |
| | 758 | x = new BigNumber('-0.785398164'); // -pi/4 -> -.707106782 |
| | 759 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 760 | |
| | 761 | x = new BigNumber('-1.57079633'); // -pi/2 -> -1.0000000 |
| | 762 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 763 | |
| | 764 | x = new BigNumber('-3.14159265'); // -pi -> 0 |
| | 765 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 766 | |
| | 767 | x = new BigNumber('-1.11111'); // -> -0.896192 |
| | 768 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 769 | |
| | 770 | x = new BigNumber('-2.0000'); // -> -0.909297 -> -.90930 |
| | 771 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 772 | |
| | 773 | x = new BigNumber('-3.010203'); // -> -.1310119 |
| | 774 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 775 | |
| | 776 | x = new BigNumber('-4.567890'); // -> .9895782 |
| | 777 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 778 | |
| | 779 | x = new BigNumber('-5.43210'); // -> .751996 |
| | 780 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 781 | |
| | 782 | x = new BigNumber('-6.012345'); // -> .2675412 |
| | 783 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 784 | |
| | 785 | x = new BigNumber('-6.305555'); // a little over -2pi -> -.02236783 |
| | 786 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 787 | |
| | 788 | x = new BigNumber('-9.350123'); // -> -0.07458563 |
| | 789 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 790 | |
| | 791 | x = new BigNumber('0.00000000'); // -> .00000000 |
| | 792 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 793 | |
| | 794 | x = new BigNumber('0.50000000'); // -> .47942554 |
| | 795 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 796 | |
| | 797 | x = new BigNumber('112'); // -> -0.88999560 -> -0.89 |
| | 798 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 799 | |
| | 800 | x = new BigNumber('112000'); // -> 0.79541568 |
| | 801 | "x = <<x>>, sin(x) = <<x.sine()>>\n"; |
| | 802 | |
| | 803 | "\b"; |
| | 804 | |
| | 805 | /* |
| | 806 | * Cosine |
| | 807 | */ |
| | 808 | x = new BigNumber('0.785398164'); // pi/4 -> 0.707106781 |
| | 809 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 810 | |
| | 811 | x = new BigNumber('1.57079633'); // pi/2 -> 0 |
| | 812 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 813 | |
| | 814 | x = new BigNumber('3.14159265'); // pi -> -1 |
| | 815 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 816 | |
| | 817 | x = new BigNumber('1.11111'); // -> .443667 |
| | 818 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 819 | |
| | 820 | x = new BigNumber('2.0000'); // -> -0.41615 |
| | 821 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 822 | |
| | 823 | x = new BigNumber('3.010203'); // -> -.9913808 |
| | 824 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 825 | |
| | 826 | x = new BigNumber('4.567890'); // -> -.1439967 |
| | 827 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 828 | |
| | 829 | x = new BigNumber('5.43210'); // -> .659167 |
| | 830 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 831 | |
| | 832 | x = new BigNumber('6.012345'); // -> .9635464 |
| | 833 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 834 | |
| | 835 | x = new BigNumber('6.305555'); // a little over 2pi -> .9997498 |
| | 836 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 837 | |
| | 838 | x = new BigNumber('9.350123'); // -> -.9972146 |
| | 839 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 840 | |
| | 841 | x = new BigNumber('-0.785398164'); // -pi/4 -> .707106781 |
| | 842 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 843 | |
| | 844 | x = new BigNumber('-1.57079633'); // -pi/2 -> 0 |
| | 845 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 846 | |
| | 847 | x = new BigNumber('-3.14159265'); // -pi -> -1 |
| | 848 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 849 | |
| | 850 | x = new BigNumber('-1.11111'); // -> 0.443667 |
| | 851 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 852 | |
| | 853 | x = new BigNumber('-2.0000'); // -> -.41615 |
| | 854 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 855 | |
| | 856 | x = new BigNumber('-3.010203'); // -> -.9913808 |
| | 857 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 858 | |
| | 859 | x = new BigNumber('-4.567890'); // -> -.1439967 |
| | 860 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 861 | |
| | 862 | x = new BigNumber('-5.43210'); // -> .659167 |
| | 863 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 864 | |
| | 865 | x = new BigNumber('-6.012345'); // -> .9635464 |
| | 866 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 867 | |
| | 868 | x = new BigNumber('-6.305555'); // a little over -2pi -> .9997498 |
| | 869 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 870 | |
| | 871 | x = new BigNumber('-9.350123'); // -> -.9972146 |
| | 872 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 873 | |
| | 874 | x = new BigNumber('0.00000000'); // -> 1 |
| | 875 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 876 | |
| | 877 | x = new BigNumber('0.50000000'); // -> .87758256 |
| | 878 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 879 | |
| | 880 | x = new BigNumber('112'); // -> .456 |
| | 881 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 882 | |
| | 883 | x = new BigNumber('112000'); // -> -.606064 |
| | 884 | "x = <<x>>, cos(x) = <<x.cosine()>>\n"; |
| | 885 | |
| | 886 | "\b"; |
| | 887 | |
| | 888 | /* |
| | 889 | * Tangent |
| | 890 | */ |
| | 891 | x = new BigNumber('0.785398164'); // pi/4 -> 1 |
| | 892 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 893 | |
| | 894 | x = new BigNumber('1.57079633'); // pi/2 -> -312012480.5 (really -INF) |
| | 895 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 896 | |
| | 897 | x = new BigNumber('3.14159265'); // pi -> 0 |
| | 898 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 899 | |
| | 900 | x = new BigNumber('1.11111'); // -> 2.01996 |
| | 901 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 902 | |
| | 903 | x = new BigNumber('2.0000'); // -> -2.1850 |
| | 904 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 905 | |
| | 906 | x = new BigNumber('3.010203'); // -> -.1321510 |
| | 907 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 908 | |
| | 909 | x = new BigNumber('4.567890'); // -> 6.872231 |
| | 910 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 911 | |
| | 912 | x = new BigNumber('5.43210'); // -> -1.14083 |
| | 913 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 914 | |
| | 915 | x = new BigNumber('6.012345'); // -> -.2776630 |
| | 916 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 917 | |
| | 918 | x = new BigNumber('6.305555'); // a little over 2pi -> .02237342 |
| | 919 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 920 | |
| | 921 | x = new BigNumber('9.350123'); // -> -.07479396 |
| | 922 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 923 | |
| | 924 | x = new BigNumber('-0.785398164'); // -pi/4 -> -1 |
| | 925 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 926 | |
| | 927 | x = new BigNumber('-1.57079633'); // -pi/2 -> 312012480.5 (really +INF) |
| | 928 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 929 | |
| | 930 | x = new BigNumber('-3.14159265'); // -pi -> 0 |
| | 931 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 932 | |
| | 933 | x = new BigNumber('-1.11111'); // -> -2.01996 |
| | 934 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 935 | |
| | 936 | x = new BigNumber('-2.0000'); // -> 2.1850 |
| | 937 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 938 | |
| | 939 | x = new BigNumber('-3.010203'); // -> .1321510 |
| | 940 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 941 | |
| | 942 | x = new BigNumber('-4.567890'); // -> -6.872231 |
| | 943 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 944 | |
| | 945 | x = new BigNumber('-5.43210'); // -> 1.14083 |
| | 946 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 947 | |
| | 948 | x = new BigNumber('-6.012345'); // -> .2776630 |
| | 949 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 950 | |
| | 951 | x = new BigNumber('-6.305555'); // a little over -2pi -> -.02237342 |
| | 952 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 953 | |
| | 954 | x = new BigNumber('-9.350123'); // -> 0.07479396 |
| | 955 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 956 | |
| | 957 | x = new BigNumber('0.00000000'); // -> 0 |
| | 958 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 959 | |
| | 960 | x = new BigNumber('0.50000000'); // -> 0.54630249 |
| | 961 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 962 | |
| | 963 | x = new BigNumber('112'); // -> -1.95 |
| | 964 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 965 | |
| | 966 | x = new BigNumber('112000'); // -> -1.31243 |
| | 967 | "x = <<x>>, tan(x) = <<x.tangent()>>\n"; |
| | 968 | |
| | 969 | "\b"; |
| | 970 | |
| | 971 | /* |
| | 972 | * Radian/degree conversions |
| | 973 | */ |
| | 974 | |
| | 975 | x = new BigNumber('90.0000'); |
| | 976 | "x = <<x>>, d2r = <<x.degreesToRadians()>>\n"; |
| | 977 | |
| | 978 | x = new BigNumber('180.000'); |
| | 979 | "x = <<x>>, d2r = <<x.degreesToRadians()>>\n"; |
| | 980 | |
| | 981 | x = new BigNumber('270.000'); |
| | 982 | "x = <<x>>, d2r = <<x.degreesToRadians()>>\n"; |
| | 983 | |
| | 984 | x = new BigNumber('360.000'); |
| | 985 | "x = <<x>>, d2r = <<x.degreesToRadians()>>\n"; |
| | 986 | |
| | 987 | x = new BigNumber('0.00000'); |
| | 988 | "x = <<x>>, d2r = <<x.degreesToRadians()>>\n"; |
| | 989 | |
| | 990 | x = new BigNumber('-90.0000'); |
| | 991 | "x = <<x>>, d2r = <<x.degreesToRadians()>>\n"; |
| | 992 | |
| | 993 | x = new BigNumber('-180.000'); |
| | 994 | "x = <<x>>, d2r = <<x.degreesToRadians()>>\n"; |
| | 995 | |
| | 996 | x = new BigNumber('3.14159265'); |
| | 997 | "x = <<x>>, r2d = <<x.radiansToDegrees()>>\n"; |
| | 998 | |
| | 999 | x = new BigNumber('-3.14159265'); |
| | 1000 | "x = <<x>>, r2d = <<x.radiansToDegrees()>>\n"; |
| | 1001 | |
| | 1002 | x = new BigNumber('0.00000'); |
| | 1003 | "x = <<x>>, r2d = <<x.radiansToDegrees()>>\n"; |
| | 1004 | |
| | 1005 | x = new BigNumber('1.57079633'); |
| | 1006 | "x = <<x>>, r2d = <<x.radiansToDegrees()>>\n"; |
| | 1007 | |
| | 1008 | x = new BigNumber('-1.57079633'); |
| | 1009 | "x = <<x>>, r2d = <<x.radiansToDegrees()>>\n"; |
| | 1010 | |
| | 1011 | "\b"; |
| | 1012 | |
| | 1013 | /* |
| | 1014 | * arcsin/arccos |
| | 1015 | */ |
| | 1016 | x = new BigNumber('0.0000000'); // 0, 1.57079633 |
| | 1017 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1018 | |
| | 1019 | x = new BigNumber('0.50000000'); // 0.52359878, 1.04719755 |
| | 1020 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1021 | |
| | 1022 | x = new BigNumber('-0.50000000'); // -.52359878, 2.09439510 |
| | 1023 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1024 | |
| | 1025 | x = new BigNumber('0.54030231'); // 0.57079633, 1 |
| | 1026 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1027 | |
| | 1028 | x = new BigNumber('-0.54030231'); // -0.57079633, 2.14159266 |
| | 1029 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1030 | |
| | 1031 | x = new BigNumber('0.70710678'); // 0.78539816, 0.78539816 |
| | 1032 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1033 | |
| | 1034 | x = new BigNumber('0.84147098'); // 1, 0.57079633 |
| | 1035 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1036 | |
| | 1037 | x = new BigNumber('0.9000000'); // 1.11976952, .45102681 |
| | 1038 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1039 | |
| | 1040 | x = new BigNumber('0.9999990'); // 1.56938211, .00141421 |
| | 1041 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1042 | |
| | 1043 | x = new BigNumber('-0.9999990'); // -1.56938211, 3.14017844 |
| | 1044 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1045 | |
| | 1046 | x = new BigNumber('1.0000000'); // 1.57079633, 0 |
| | 1047 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1048 | |
| | 1049 | x = new BigNumber('-1.0000000'); // -1.57079633, 3.14159265 |
| | 1050 | "x = <<x>>, asin = <<x.arcsine()>>, acos = <<x.arccosine()>>\n"; |
| | 1051 | |
| | 1052 | "\b"; |
| | 1053 | |
| | 1054 | /* |
| | 1055 | * arctan |
| | 1056 | */ |
| | 1057 | x = new BigNumber('0.0000000'); |
| | 1058 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1059 | |
| | 1060 | x = new BigNumber('1.2345678e-4'); |
| | 1061 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1062 | |
| | 1063 | x = new BigNumber('-1.2345678e-4'); |
| | 1064 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1065 | |
| | 1066 | x = new BigNumber('0.2500000'); |
| | 1067 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1068 | |
| | 1069 | x = new BigNumber('-0.2500000'); |
| | 1070 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1071 | |
| | 1072 | x = new BigNumber('1.0000000'); |
| | 1073 | "x = <<x>>, atan = <<x.arctangent()>>, atan(1)*4 = |
| | 1074 | <<x.arctangent() * 4>>\n"; |
| | 1075 | |
| | 1076 | x = new BigNumber('-1.0000000'); |
| | 1077 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1078 | |
| | 1079 | x = new BigNumber('3.14159265'); |
| | 1080 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1081 | |
| | 1082 | x = new BigNumber('-3.14159265'); |
| | 1083 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1084 | |
| | 1085 | x = new BigNumber('123.45678'); |
| | 1086 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1087 | |
| | 1088 | x = new BigNumber('-123.45678'); |
| | 1089 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1090 | |
| | 1091 | x = new BigNumber('9876.54321'); |
| | 1092 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1093 | |
| | 1094 | x = new BigNumber('-9876.54321'); |
| | 1095 | "x = <<x>>, atan = <<x.arctangent()>>\n"; |
| | 1096 | |
| | 1097 | "\b"; |
| | 1098 | |
| | 1099 | /* |
| | 1100 | * square root |
| | 1101 | */ |
| | 1102 | x = new BigNumber('1234.5678'); |
| | 1103 | "x = <<x>>, sqrt = <<x.sqrt()>>\n"; |
| | 1104 | |
| | 1105 | x = new BigNumber('12345.678'); |
| | 1106 | "x = <<x>>, sqrt = <<x.sqrt()>>\n"; |
| | 1107 | |
| | 1108 | x = new BigNumber('987.65432'); |
| | 1109 | "x = <<x>>, sqrt = <<x.sqrt()>>\n"; |
| | 1110 | |
| | 1111 | x = new BigNumber('9876.5432'); |
| | 1112 | "x = <<x>>, sqrt = <<x.sqrt()>>\n"; |
| | 1113 | |
| | 1114 | x = new BigNumber('2.0000000'); |
| | 1115 | "x = <<x>>, sqrt = <<x.sqrt()>>\n"; |
| | 1116 | |
| | 1117 | x = new BigNumber('0.20000000'); |
| | 1118 | "x = <<x>>, sqrt = <<x.sqrt()>>\n"; |
| | 1119 | |
| | 1120 | "\b"; |
| | 1121 | |
| | 1122 | /* |
| | 1123 | * log |
| | 1124 | */ |
| | 1125 | x = new BigNumber('3.04050607e-10'); |
| | 1126 | "x = <<x.formatString(10, BignumExp)>>, ln = <<x.logE()>>\n"; |
| | 1127 | |
| | 1128 | x = new BigNumber('0.50267771'); |
| | 1129 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1130 | |
| | 1131 | x = new BigNumber('0.750750750'); |
| | 1132 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1133 | |
| | 1134 | x = new BigNumber('0.999888777'); |
| | 1135 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1136 | |
| | 1137 | x = new BigNumber('1.00000000'); |
| | 1138 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1139 | |
| | 1140 | x = new BigNumber('1.00000123'); |
| | 1141 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1142 | |
| | 1143 | x = new BigNumber('1.99999999'); |
| | 1144 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1145 | |
| | 1146 | x = new BigNumber('2.00000001'); |
| | 1147 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1148 | |
| | 1149 | x = new BigNumber('11.7512345'); |
| | 1150 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1151 | |
| | 1152 | x = new BigNumber('1234567890'); |
| | 1153 | "x = <<x>>, ln = <<x.logE()>>\n"; |
| | 1154 | |
| | 1155 | x = new BigNumber('9.8765432e50'); |
| | 1156 | "x = <<x.formatString(10, BignumExp)>>, ln = <<x.logE()>>\n"; |
| | 1157 | |
| | 1158 | "\b"; |
| | 1159 | |
| | 1160 | /* |
| | 1161 | * exp |
| | 1162 | */ |
| | 1163 | x = new BigNumber('5.000000e-17'); |
| | 1164 | "x = <<x.formatString(10, BignumExp)>>, exp = <<x.expE()>>\n"; |
| | 1165 | |
| | 1166 | x = new BigNumber('-5.000000e-17'); |
| | 1167 | "x = <<x.formatString(10, BignumExp)>>, exp = <<x.expE()>>\n"; |
| | 1168 | |
| | 1169 | x = new BigNumber('.000500000'); |
| | 1170 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1171 | |
| | 1172 | x = new BigNumber('-.000500000'); |
| | 1173 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1174 | |
| | 1175 | x = new BigNumber('.500000'); |
| | 1176 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1177 | |
| | 1178 | x = new BigNumber('-.500000'); |
| | 1179 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1180 | |
| | 1181 | x = new BigNumber('1.00000'); |
| | 1182 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1183 | |
| | 1184 | x = new BigNumber('-1.00000'); |
| | 1185 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1186 | |
| | 1187 | x = new BigNumber('1.50000'); |
| | 1188 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1189 | |
| | 1190 | x = new BigNumber('-1.50000'); |
| | 1191 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1192 | |
| | 1193 | x = new BigNumber('2.30000'); |
| | 1194 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1195 | |
| | 1196 | x = new BigNumber('-2.30000'); |
| | 1197 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1198 | |
| | 1199 | x = new BigNumber('15.00000'); |
| | 1200 | "x = <<x>>, exp = <<x.expE().formatString(10, BignumExp)>>\n"; |
| | 1201 | |
| | 1202 | x = new BigNumber('-15.0000'); |
| | 1203 | "x = <<x>>, exp = <<x.expE().formatString(10, BignumExp)>>\n"; |
| | 1204 | |
| | 1205 | x = new BigNumber('150.000000'); |
| | 1206 | "x = <<x>>, exp = <<x.expE().formatString(10, BignumExp)>>\n"; |
| | 1207 | |
| | 1208 | x = new BigNumber('-150.00000'); |
| | 1209 | "x = <<x>>, exp = <<x.expE().formatString(10, BignumExp)>>\n"; |
| | 1210 | |
| | 1211 | x = new BigNumber('1500'); |
| | 1212 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1213 | |
| | 1214 | x = new BigNumber('-1500'); |
| | 1215 | "x = <<x>>, exp = <<x.expE()>>\n"; |
| | 1216 | |
| | 1217 | "\b"; |
| | 1218 | |
| | 1219 | /* |
| | 1220 | * log10 tests |
| | 1221 | */ |
| | 1222 | x = new BigNumber('0.00001000'); |
| | 1223 | "x = <<x>>, log10 = <<x.log10()>>\n"; |
| | 1224 | |
| | 1225 | x = new BigNumber('0.10000000'); |
| | 1226 | "x = <<x>>, log10 = <<x.log10()>>\n"; |
| | 1227 | |
| | 1228 | x = new BigNumber('1.00000000'); |
| | 1229 | "x = <<x>>, log10 = <<x.log10()>>\n"; |
| | 1230 | |
| | 1231 | x = new BigNumber('10.0000000'); |
| | 1232 | "x = <<x>>, log10 = <<x.log10()>>\n"; |
| | 1233 | |
| | 1234 | x = new BigNumber('1.000000e23'); |
| | 1235 | "x = <<x.formatString(10, BignumExp)>>, log10 = <<x.log10()>>\n"; |
| | 1236 | |
| | 1237 | x = new BigNumber('1234567890'); |
| | 1238 | "x = <<x>>, log10 = <<x.log10()>>\n"; |
| | 1239 | |
| | 1240 | x = new BigNumber('345676543'); |
| | 1241 | "x = <<x>>, log10 = <<x.log10()>>\n"; |
| | 1242 | |
| | 1243 | "\b"; |
| | 1244 | |
| | 1245 | /* |
| | 1246 | * power tests |
| | 1247 | */ |
| | 1248 | x = new BigNumber('5.123456'); |
| | 1249 | y = new BigNumber('7.890123'); |
| | 1250 | "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; |
| | 1251 | |
| | 1252 | x = new BigNumber('52.123456'); |
| | 1253 | y = new BigNumber('-7.890123'); |
| | 1254 | "x = <<x>>, y = <<y>>, |
| | 1255 | x^y = <<x.raiseToPower(y).formatString(10, BignumExp)>>\n"; |
| | 1256 | |
| | 1257 | x = new BigNumber('-3.123456'); |
| | 1258 | y = new BigNumber('7'); |
| | 1259 | "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; |
| | 1260 | |
| | 1261 | x = new BigNumber('-5.123456'); |
| | 1262 | y = new BigNumber('-7'); |
| | 1263 | "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; |
| | 1264 | |
| | 1265 | x = new BigNumber('-3.123456'); |
| | 1266 | y = new BigNumber('6'); |
| | 1267 | "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; |
| | 1268 | |
| | 1269 | x = new BigNumber('-5.123456'); |
| | 1270 | y = new BigNumber('-6'); |
| | 1271 | "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; |
| | 1272 | |
| | 1273 | x = new BigNumber('0.00005234991'); |
| | 1274 | y = new BigNumber('0.00006781234'); |
| | 1275 | "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; |
| | 1276 | |
| | 1277 | x = new BigNumber('0.000000'); |
| | 1278 | y = new BigNumber('1.000000'); |
| | 1279 | "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; |
| | 1280 | |
| | 1281 | x = new BigNumber('12.000000'); |
| | 1282 | y = new BigNumber('0.000000'); |
| | 1283 | "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; |
| | 1284 | |
| | 1285 | x = new BigNumber('0.000000'); |
| | 1286 | y = new BigNumber('0.000000'); |
| | 1287 | try { "x = <<x>>, y = <<y>>, x^y = <<x.raiseToPower(y)>>\n"; } |
| | 1288 | catch (RuntimeError err) { "error: <<err.exceptionMessage>>\n"; } |
| | 1289 | |
| | 1290 | "\b"; |
| | 1291 | |
| | 1292 | /* |
| | 1293 | * hyperbolic sine, cosine, and tangent |
| | 1294 | */ |
| | 1295 | |
| | 1296 | x = new BigNumber('0.0000000'); |
| | 1297 | "x = <<x>>, sinh=<<x.sinh()>>, cosh=<<x.cosh()>>, tahn=<<x.tanh()>>\n"; |
| | 1298 | |
| | 1299 | x = new BigNumber('1.0000000'); |
| | 1300 | "x = <<x>>, sinh=<<x.sinh()>>, cosh=<<x.cosh()>>, tahn=<<x.tanh()>>\n"; |
| | 1301 | |
| | 1302 | x = new BigNumber('-1.0000000'); |
| | 1303 | "x = <<x>>, sinh=<<x.sinh()>>, cosh=<<x.cosh()>>, tahn=<<x.tanh()>>\n"; |
| | 1304 | |
| | 1305 | x = new BigNumber('2.5300000'); |
| | 1306 | "x = <<x>>, sinh=<<x.sinh()>>, cosh=<<x.cosh()>>, tahn=<<x.tanh()>>\n"; |
| | 1307 | |
| | 1308 | x = new BigNumber('-2.5300000'); |
| | 1309 | "x = <<x>>, sinh=<<x.sinh()>>, cosh=<<x.cosh()>>, tahn=<<x.tanh()>>\n"; |
| | 1310 | |
| | 1311 | "\b"; |
| | 1312 | |
| | 1313 | /* |
| | 1314 | * min/max |
| | 1315 | */ |
| | 1316 | x = new BigNumber('1.000'); |
| | 1317 | y = new BigNumber('-3.000'); |
| | 1318 | z = new BigNumber('2.000'); |
| | 1319 | "x = <<x>>, y = <<y>>, z = <<z>>, min = <<min(x, y, z)>>, |
| | 1320 | max = <<max(x, y, z)>>\n"; |
| | 1321 | "(x,y,z,-11,7): min = <<min(x, y, z, -11, 7)>>, |
| | 1322 | max = <<max(x, y, z, -11, 7)>>\n"; |
| | 1323 | "max(z, y, x) = <<max(z, y, x)>>, max(y, x, z) = <<max(y, x, z)>>\n"; |
| | 1324 | "min(z, y, x) = <<min(z, y, x)>>, min(y, x, z) = <<min(y, x, z)>>\n"; |
| | 1325 | |
| | 1326 | "\b"; |
| | 1327 | } |
| | 1328 | |
| | 1329 | bool(val) |
| | 1330 | { |
| | 1331 | if (val) |
| | 1332 | "true"; |
| | 1333 | else |
| | 1334 | "nil"; |
| | 1335 | } |
| | 1336 | |
| | 1337 | preinit() |
| | 1338 | { |
| | 1339 | } |
| | 1340 | |
| | 1341 | |