mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-28 20:43:38 +01:00
37 lines
20 KiB
C
37 lines
20 KiB
C
|
/*
|
||
|
Copyright (c) 2009 Florian Loitsch
|
||
|
|
||
|
Permission is hereby granted, free of charge, to any person
|
||
|
obtaining a copy of this software and associated documentation
|
||
|
files (the "Software"), to deal in the Software without
|
||
|
restriction, including without limitation the rights to use,
|
||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
|
copies of the Software, and to permit persons to whom the
|
||
|
Software is furnished to do so, subject to the following
|
||
|
conditions:
|
||
|
|
||
|
The above copyright notice and this permission notice shall be
|
||
|
included in all copies or substantial portions of the Software.
|
||
|
|
||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||
|
*/
|
||
|
#include <stdint.h>
|
||
|
|
||
|
#define DIY_SIGNIFICAND_SIZE 64
|
||
|
static const uint64_t powers_ten[] = {0xbf29dcaba82fdeae , 0xeef453d6923bd65a , 0x9558b4661b6565f8 , 0xbaaee17fa23ebf76 , 0xe95a99df8ace6f54 , 0x91d8a02bb6c10594 , 0xb64ec836a47146fa , 0xe3e27a444d8d98b8 , 0x8e6d8c6ab0787f73 , 0xb208ef855c969f50 , 0xde8b2b66b3bc4724 , 0x8b16fb203055ac76 , 0xaddcb9e83c6b1794 , 0xd953e8624b85dd79 , 0x87d4713d6f33aa6c , 0xa9c98d8ccb009506 , 0xd43bf0effdc0ba48 , 0x84a57695fe98746d , 0xa5ced43b7e3e9188 , 0xcf42894a5dce35ea , 0x818995ce7aa0e1b2 , 0xa1ebfb4219491a1f , 0xca66fa129f9b60a7 , 0xfd00b897478238d1 , 0x9e20735e8cb16382 , 0xc5a890362fddbc63 , 0xf712b443bbd52b7c , 0x9a6bb0aa55653b2d , 0xc1069cd4eabe89f9 , 0xf148440a256e2c77 , 0x96cd2a865764dbca , 0xbc807527ed3e12bd , 0xeba09271e88d976c , 0x93445b8731587ea3 , 0xb8157268fdae9e4c , 0xe61acf033d1a45df , 0x8fd0c16206306bac , 0xb3c4f1ba87bc8697 , 0xe0b62e2929aba83c , 0x8c71dcd9ba0b4926 , 0xaf8e5410288e1b6f , 0xdb71e91432b1a24b , 0x892731ac9faf056f , 0xab70fe17c79ac6ca , 0xd64d3d9db981787d , 0x85f0468293f0eb4e , 0xa76c582338ed2622 , 0xd1476e2c07286faa , 0x82cca4db847945ca , 0xa37fce126597973d , 0xcc5fc196fefd7d0c , 0xff77b1fcbebcdc4f , 0x9faacf3df73609b1 , 0xc795830d75038c1e , 0xf97ae3d0d2446f25 , 0x9becce62836ac577 , 0xc2e801fb244576d5 , 0xf3a20279ed56d48a , 0x9845418c345644d7 , 0xbe5691ef416bd60c , 0xedec366b11c6cb8f , 0x94b3a202eb1c3f39 , 0xb9e08a83a5e34f08 , 0xe858ad248f5c22ca , 0x91376c36d99995be , 0xb58547448ffffb2e , 0xe2e69915b3fff9f9 , 0x8dd01fad907ffc3c , 0xb1442798f49ffb4b , 0xdd95317f31c7fa1d , 0x8a7d3eef7f1cfc52 , 0xad1c8eab5ee43b67 , 0xd863b256369d4a41 , 0x873e4f75e2224e68 , 0xa90de3535aaae202 , 0xd3515c2831559a83 , 0x8412d9991ed58092 , 0xa5178fff668ae0b6 , 0xce5d73ff402d98e4 , 0x80fa687f881c7f8e , 0xa139029f6a239f72 , 0xc987434744ac874f , 0xfbe9141915d7a922 , 0x9d71ac8fada6c9b5 , 0xc4ce17b399107c23 , 0xf6019da07f549b2b , 0x99c102844f94e0fb , 0xc0314325637a193a , 0xf03d93eebc589f88 , 0x96267c7535b763b5 , 0xbbb01b9283253ca3 , 0xea9c227723ee8bcb , 0x92a1958a7675175f , 0xb749faed14125d37 , 0xe51c79a85916f485 , 0x8f31cc0937ae58d3 , 0xb2fe3f0b8599ef08 , 0xdfbdcece67006ac9 , 0x8bd6a141006042be , 0xaecc49914078536d , 0xda7f5bf590966849 , 0x888f99797a5e012d , 0xaab37fd7d8f58179 , 0xd5605fcdcf32e1d7 , 0x855c3be0a17fcd26 , 0xa6b34ad8c9dfc070 , 0xd0601d8efc57b08c , 0x823c12795db6ce57 , 0xa2cb1717b52481ed , 0xcb7ddcdda26da269 , 0xfe5d54150b090b03 , 0x9efa548d26e5a6e2 , 0xc6b8e9b0709f109a , 0xf867241c8cc6d4c1 , 0x9b407691d7fc44f8 , 0xc21094364dfb5637 , 0xf294b943e17a2bc4 , 0x979cf3ca6cec5b5b , 0xbd8430bd08277231 , 0xece53cec4a314ebe , 0x940f4613ae5ed137 , 0xb913179899f68584 , 0xe757dd7ec07426e5 , 0x9096ea6f3848984f , 0xb4bca50b065abe63 , 0xe1ebce4dc7f16dfc , 0x8d3360f09cf6e4bd , 0xb080392cc4349ded , 0xdca04777f541c568 , 0x89e42caaf9491b61 , 0xac5d37d5b79b6239 , 0xd77485cb25823ac7 , 0x86a8d39ef77164bd , 0xa8530886b54dbdec , 0xd267caa862a12d67 , 0x8380dea93da4bc60 , 0xa46116538d0deb78 , 0xcd795be870516656 , 0x806bd9714632dff6 , 0xa086cfcd97bf97f4 , 0xc8a883c0fdaf7df0 , 0xfad2a4b13d1b5d6c , 0x9cc3a6eec6311a64 , 0xc3f490aa77bd60fd , 0xf4f1b4d515acb93c , 0x991711052d8bf3c5 , 0xbf5cd54678eef0b7 , 0xef340a98172aace5 , 0x9580869f0e7aac0f , 0xbae0a846d2195713 , 0xe998d258869facd7 , 0x91ff83775423cc06 , 0xb67f6455292cbf08 , 0xe41f3d6a7377eeca , 0x8e938662882af53e , 0xb23867fb2a35b28e , 0xdec681f9f4c31f31 , 0x8b3c113c38f9f37f , 0xae0b158b4738705f , 0xd98ddaee19068c76 , 0x87f8a8d4cfa417ca , 0xa9f6d30a038d1dbc , 0xd47487cc8470652b , 0x84c8d4dfd2c63f3b , 0xa5fb0a17c777cf0a , 0xcf79cc9db955c2cc , 0x81ac1fe293d599c0 , 0xa21727db38cb0030 , 0xca9cf1d206fdc03c , 0xfd442e4688bd304b , 0x9e4a9cec15763e2f , 0xc5dd44271ad3cdba , 0xf7549530e188c129 , 0x9a94dd3e8cf578ba , 0xc13a148e3032d6e8 , 0xf18899b1bc3f8ca2 , 0x96f5600f15a7b7e5 , 0xbcb2b812db11a5de , 0xebdf661791d60f56 , 0x936b9fcebb25c996 , 0xb84687c269ef3bfb , 0xe65829b3046b0afa , 0x8ff71a0fe2c2e6dc , 0xb3f4e093db73a093 , 0xe0f218b8d25088b8 , 0x8c974f7383725573 , 0xafbd2350644eead0 , 0xdbac6c247d62a584 , 0x894bc396ce5da772 , 0xab9eb47c81f5114f , 0xd686619ba27255a3 , 0x8613fd0145877586 , 0xa798fc4196e952e7 , 0xd1
|
||
|
static const int powers_ten_e[] = {-1203 , -1200 , -1196 , -1193 , -1190 , -1186 , -1183 , -1180 , -1176 , -1173 , -1170 , -1166 , -1163 , -1160 , -1156 , -1153 , -1150 , -1146 , -1143 , -1140 , -1136 , -1133 , -1130 , -1127 , -1123 , -1120 , -1117 , -1113 , -1110 , -1107 , -1103 , -1100 , -1097 , -1093 , -1090 , -1087 , -1083 , -1080 , -1077 , -1073 , -1070 , -1067 , -1063 , -1060 , -1057 , -1053 , -1050 , -1047 , -1043 , -1040 , -1037 , -1034 , -1030 , -1027 , -1024 , -1020 , -1017 , -1014 , -1010 , -1007 , -1004 , -1000 , -997 , -994 , -990 , -987 , -984 , -980 , -977 , -974 , -970 , -967 , -964 , -960 , -957 , -954 , -950 , -947 , -944 , -940 , -937 , -934 , -931 , -927 , -924 , -921 , -917 , -914 , -911 , -907 , -904 , -901 , -897 , -894 , -891 , -887 , -884 , -881 , -877 , -874 , -871 , -867 , -864 , -861 , -857 , -854 , -851 , -847 , -844 , -841 , -838 , -834 , -831 , -828 , -824 , -821 , -818 , -814 , -811 , -808 , -804 , -801 , -798 , -794 , -791 , -788 , -784 , -781 , -778 , -774 , -771 , -768 , -764 , -761 , -758 , -754 , -751 , -748 , -744 , -741 , -738 , -735 , -731 , -728 , -725 , -721 , -718 , -715 , -711 , -708 , -705 , -701 , -698 , -695 , -691 , -688 , -685 , -681 , -678 , -675 , -671 , -668 , -665 , -661 , -658 , -655 , -651 , -648 , -645 , -642 , -638 , -635 , -632 , -628 , -625 , -622 , -618 , -615 , -612 , -608 , -605 , -602 , -598 , -595 , -592 , -588 , -585 , -582 , -578 , -575 , -572 , -568 , -565 , -562 , -558 , -555 , -552 , -549 , -545 , -542 , -539 , -535 , -532 , -529 , -525 , -522 , -519 , -515 , -512 , -509 , -505 , -502 , -499 , -495 , -492 , -489 , -485 , -482 , -479 , -475 , -472 , -469 , -465 , -462 , -459 , -455 , -452 , -449 , -446 , -442 , -439 , -436 , -432 , -429 , -426 , -422 , -419 , -416 , -412 , -409 , -406 , -402 , -399 , -396 , -392 , -389 , -386 , -382 , -379 , -376 , -372 , -369 , -366 , -362 , -359 , -356 , -353 , -349 , -346 , -343 , -339 , -336 , -333 , -329 , -326 , -323 , -319 , -316 , -313 , -309 , -306 , -303 , -299 , -296 , -293 , -289 , -286 , -283 , -279 , -276 , -273 , -269 , -266 , -263 , -259 , -256 , -253 , -250 , -246 , -243 , -240 , -236 , -233 , -230 , -226 , -223 , -220 , -216 , -213 , -210 , -206 , -203 , -200 , -196 , -193 , -190 , -186 , -183 , -180 , -176 , -173 , -170 , -166 , -163 , -160 , -157 , -153 , -150 , -147 , -143 , -140 , -137 , -133 , -130 , -127 , -123 , -120 , -117 , -113 , -110 , -107 , -103 , -100 , -97 , -93 , -90 , -87 , -83 , -80 , -77 , -73 , -70 , -67 , -63 , -60 , -57 , -54 , -50 , -47 , -44 , -40 , -37 , -34 , -30 , -27 , -24 , -20 , -17 , -14 , -10 , -7 , -4 , 0 , 3 , 6 , 10 , 13 , 16 , 20 , 23 , 26 , 30 , 33 , 36 , 39 , 43 , 46 , 49 , 53 , 56 , 59 , 63 , 66 , 69 , 73 , 76 , 79 , 83 , 86 , 89 , 93 , 96 , 99 , 103 , 106 , 109 , 113 , 116 , 119 , 123 , 126 , 129 , 132 , 136 , 139 , 142 , 146 , 149 , 152 , 156 , 159 , 162 , 166 , 169 , 172 , 176 , 179 , 182 , 186 , 189 , 192 , 196 , 199 , 202 , 206 , 209 , 212 , 216 , 219 , 222 , 226 , 229 , 232 , 235 , 239 , 242 , 245 , 249 , 252 , 255 , 259 , 262 , 265 , 269 , 272 , 275 , 279 , 282 , 285 , 289 , 292 , 295 , 299 , 302 , 305 , 309 , 312 , 315 , 319 , 322 , 325 , 328 , 332 , 335 , 338 , 342 , 345 , 348 , 352 , 355 , 358 , 362 , 365 , 368 , 372 , 375 , 378 , 382 , 385 , 388 , 392 , 395 , 398 , 402 , 405 , 408 , 412 , 415 , 418 , 422 , 425 , 428 , 431 , 435 , 438 , 441 , 445 , 448 , 451 , 455 , 458 , 461 , 465 , 468 , 471 , 475 , 478 , 481 , 485 , 488 , 491 , 495 , 498 , 501 , 505 , 508 , 511 , 515 , 518 , 521 , 524 , 528 , 531 , 534 , 538 , 541 , 544 , 548 , 551 , 554 , 558 , 561 , 564 , 568 , 571 , 574 , 578 , 581 , 584 , 588 , 591 , 594 , 598 , 601 , 604 , 608 , 611 , 614 , 617 , 621 , 624 , 627 , 631 , 634 , 637 , 641 , 644 , 647 , 651 , 654 , 657 , 661 , 664 , 667 , 671 , 674 , 677 , 681 , 684 , 687 , 691 , 694 , 697 , 701 , 704 , 707 , 711 , 714 , 717 , 720 , 724 , 727 , 730 , 734 , 737 , 740 , 744 , 747 , 750 , 754 , 757 , 760 , 764 , 767 , 770 , 774 , 777 , 780 , 784 , 787 , 790 , 794 , 797 , 800 , 804 , 807 , 810 , 813 , 817 , 820 , 823 , 827 , 830 , 833 , 837 , 840 , 843 ,
|
||
|
static diy_fp_t cached_power(int k) {
|
||
|
diy_fp_t res;
|
||
|
int index = 343 + k;
|
||
|
res.f = powers_ten[index];
|
||
|
res.e = powers_ten_e[index];
|
||
|
return res;
|
||
|
}
|