From a860ee78911ea2c6efd2a8268108423295be50dc Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Wed, 16 Oct 2019 01:15:07 +0800 Subject: [PATCH] Fix preciseExp10 --- .../queries/0_stateless/00534_exp10.reference | 1311 +++++++++++++---- .../tests/queries/0_stateless/00534_exp10.sql | 3 +- libs/libcommon/src/preciseExp10.c | 82 +- 3 files changed, 1049 insertions(+), 347 deletions(-) diff --git a/dbms/tests/queries/0_stateless/00534_exp10.reference b/dbms/tests/queries/0_stateless/00534_exp10.reference index bba2c07fb64..5f55c6a4420 100644 --- a/dbms/tests/queries/0_stateless/00534_exp10.reference +++ b/dbms/tests/queries/0_stateless/00534_exp10.reference @@ -1,310 +1,1001 @@ -0 1 -1 10 -2 100 -3 1000 -4 10000 -5 100000 -6 1000000 -7 10000000 -8 100000000 -9 1000000000 -10 10000000000 -11 100000000000 -12 1000000000000 -13 10000000000000 -14 100000000000000 -15 1000000000000000 -16 10000000000000000 -17 100000000000000000 -18 1000000000000000000 -19 10000000000000000000 -20 100000000000000000000 -21 1e21 -22 1e22 -23 1e23 -24 1e24 -25 1e25 -26 1e26 -27 1e27 -28 1e28 -29 1e29 -30 1e30 -31 1e31 -32 1e32 -33 1e33 -34 1e34 -35 1e35 -36 1e36 -37 1e37 -38 1e38 -39 1e39 -40 1e40 -41 1e41 -42 1e42 -43 1e43 -44 1e44 -45 1e45 -46 1e46 -47 1e47 -48 1e48 -49 1e49 -50 1e50 -51 1e51 -52 1e52 -53 1e53 -54 1e54 -55 1e55 -56 1e56 -57 1e57 -58 1e58 -59 1e59 -60 1e60 -61 1e61 -62 1e62 -63 1e63 -64 1e64 -65 1e65 -66 1e66 -67 1e67 -68 1e68 -69 1e69 -70 1e70 -71 1e71 -72 1e72 -73 1e73 -74 1e74 -75 1e75 -76 1e76 -77 1e77 -78 1e78 -79 1e79 -80 1e80 -81 1e81 -82 1e82 -83 1e83 -84 1e84 -85 1e85 -86 1e86 -87 1e87 -88 1e88 -89 1e89 -90 1e90 -91 1e91 -92 1e92 -93 1e93 -94 1e94 -95 1e95 -96 1e96 -97 1e97 -98 1e98 -99 1e99 -100 1e100 -101 1e101 -102 1e102 -103 1e103 -104 1e104 -105 1e105 -106 1e106 -107 1e107 -108 1e108 -109 1e109 -110 1e110 -111 1e111 -112 1e112 -113 1e113 -114 1e114 -115 1e115 -116 1e116 -117 1e117 -118 1e118 -119 1e119 -120 1e120 -121 1e121 -122 1e122 -123 1e123 -124 1e124 -125 1e125 -126 1e126 -127 1e127 -128 1e128 -129 1e129 -130 1e130 -131 1e131 -132 1e132 -133 1e133 -134 1e134 -135 1e135 -136 1e136 -137 1e137 -138 1e138 -139 1e139 -140 1e140 -141 1e141 -142 1e142 -143 1e143 -144 1e144 -145 1e145 -146 1e146 -147 1e147 -148 1e148 -149 1e149 -150 1e150 -151 1e151 -152 1e152 -153 1e153 -154 1e154 -155 1e155 -156 1e156 -157 1e157 -158 1e158 -159 1e159 -160 1e160 -161 1e161 -162 1e162 -163 1e163 -164 1e164 -165 1e165 -166 1e166 -167 1e167 -168 1e168 -169 1e169 -170 1e170 -171 1e171 -172 1e172 -173 1e173 -174 1e174 -175 1e175 -176 1e176 -177 1e177 -178 1e178 -179 1e179 -180 1e180 -181 1e181 -182 1e182 -183 1e183 -184 1e184 -185 1e185 -186 1e186 -187 1e187 -188 1e188 -189 1e189 -190 1e190 -191 1e191 -192 1e192 -193 1e193 -194 1e194 -195 1e195 -196 1e196 -197 1e197 -198 1e198 -199 1e199 -200 1e200 -201 1e201 -202 1e202 -203 1e203 -204 1e204 -205 1e205 -206 1e206 -207 1e207 -208 1e208 -209 1e209 -210 1e210 -211 1e211 -212 1e212 -213 1e213 -214 1e214 -215 1e215 -216 1e216 -217 1e217 -218 1e218 -219 1e219 -220 1e220 -221 1e221 -222 1e222 -223 1e223 -224 1e224 -225 1e225 -226 1e226 -227 1e227 -228 1e228 -229 1e229 -230 1e230 -231 1e231 -232 1e232 -233 1e233 -234 1e234 -235 1e235 -236 1e236 -237 1e237 -238 1e238 -239 1e239 -240 1e240 -241 1e241 -242 1e242 -243 1e243 -244 1e244 -245 1e245 -246 1e246 -247 1e247 -248 1e248 -249 1e249 -250 1e250 -251 1e251 -252 1e252 -253 1e253 -254 1e254 -255 1e255 -256 1e256 -257 1e257 -258 1e258 -259 1e259 -260 1e260 -261 1e261 -262 1e262 -263 1e263 -264 1e264 -265 1e265 -266 1e266 -267 1e267 -268 1e268 -269 1e269 -270 1e270 -271 1e271 -272 1e272 -273 1e273 -274 1e274 -275 1e275 -276 1e276 -277 1e277 -278 1e278 -279 1e279 -280 1e280 -281 1e281 -282 1e282 -283 1e283 -284 1e284 -285 1e285 -286 1e286 -287 1e287 -288 1e288 -289 1e289 -290 1e290 -291 1e291 -292 1e292 -293 1e293 -294 1e294 -295 1e295 -296 1e296 -297 1e297 -298 1e298 -299 1e299 -300 1e300 -301 1e301 -302 1e302 -303 1e303 -304 1e304 -305 1e305 -306 1e306 -307 1e307 -308 1e308 -309 inf +0 0 +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +10 0 +11 0 +12 0 +13 0 +14 0 +15 0 +16 0 +17 0 +18 0 +19 0 +20 0 +21 0 +22 0 +23 0 +24 0 +25 0 +26 0 +27 0 +28 0 +29 0 +30 0 +31 0 +32 0 +33 0 +34 0 +35 0 +36 0 +37 0 +38 0 +39 0 +40 0 +41 0 +42 0 +43 0 +44 0 +45 0 +46 0 +47 0 +48 0 +49 0 +50 0 +51 0 +52 0 +53 0 +54 0 +55 0 +56 0 +57 0 +58 0 +59 0 +60 0 +61 0 +62 0 +63 0 +64 0 +65 0 +66 0 +67 0 +68 0 +69 0 +70 0 +71 0 +72 0 +73 0 +74 0 +75 0 +76 0 +77 0 +78 0 +79 0 +80 0 +81 0 +82 0 +83 0 +84 0 +85 0 +86 0 +87 0 +88 0 +89 0 +90 0 +91 0 +92 0 +93 0 +94 0 +95 0 +96 0 +97 0 +98 0 +99 0 +100 0 +101 0 +102 0 +103 0 +104 0 +105 0 +106 0 +107 0 +108 0 +109 0 +110 0 +111 0 +112 0 +113 0 +114 0 +115 0 +116 0 +117 0 +118 0 +119 0 +120 0 +121 0 +122 0 +123 0 +124 0 +125 0 +126 0 +127 0 +128 0 +129 0 +130 0 +131 0 +132 0 +133 0 +134 0 +135 0 +136 0 +137 0 +138 0 +139 0 +140 0 +141 0 +142 0 +143 0 +144 0 +145 0 +146 0 +147 0 +148 0 +149 0 +150 0 +151 0 +152 0 +153 0 +154 0 +155 0 +156 0 +157 0 +158 0 +159 0 +160 0 +161 0 +162 0 +163 0 +164 0 +165 0 +166 0 +167 0 +168 0 +169 0 +170 0 +171 0 +172 0 +173 0 +174 0 +175 0 +176 0 +177 1e-323 +178 1e-322 +179 1e-321 +180 1e-320 +181 1e-319 +182 1e-318 +183 1e-317 +184 1e-316 +185 1e-315 +186 1e-314 +187 1e-313 +188 1e-312 +189 1e-311 +190 1e-310 +191 1e-309 +192 1e-308 +193 1e-307 +194 1e-306 +195 1e-305 +196 1e-304 +197 1e-303 +198 1e-302 +199 1e-301 +200 1e-300 +201 1e-299 +202 1e-298 +203 1e-297 +204 1e-296 +205 1e-295 +206 1e-294 +207 1e-293 +208 1e-292 +209 1e-291 +210 1e-290 +211 1e-289 +212 1e-288 +213 1e-287 +214 1e-286 +215 1e-285 +216 1e-284 +217 1e-283 +218 1e-282 +219 1e-281 +220 1e-280 +221 1e-279 +222 1e-278 +223 1e-277 +224 1e-276 +225 1e-275 +226 1e-274 +227 1e-273 +228 1e-272 +229 1e-271 +230 1e-270 +231 1e-269 +232 1e-268 +233 1e-267 +234 1e-266 +235 1e-265 +236 1e-264 +237 1e-263 +238 1e-262 +239 1e-261 +240 1e-260 +241 1e-259 +242 1e-258 +243 1e-257 +244 1e-256 +245 1e-255 +246 1e-254 +247 1e-253 +248 1e-252 +249 1e-251 +250 1e-250 +251 1e-249 +252 1e-248 +253 1e-247 +254 1e-246 +255 1e-245 +256 1e-244 +257 1e-243 +258 1e-242 +259 1e-241 +260 1e-240 +261 1e-239 +262 1e-238 +263 1e-237 +264 1e-236 +265 1e-235 +266 1e-234 +267 1e-233 +268 1e-232 +269 1e-231 +270 1e-230 +271 1e-229 +272 1e-228 +273 1e-227 +274 1e-226 +275 1e-225 +276 1e-224 +277 1e-223 +278 1e-222 +279 1e-221 +280 1e-220 +281 1e-219 +282 1e-218 +283 1e-217 +284 1e-216 +285 1e-215 +286 1e-214 +287 1e-213 +288 1e-212 +289 1e-211 +290 1e-210 +291 1e-209 +292 1e-208 +293 1e-207 +294 1e-206 +295 1e-205 +296 1e-204 +297 1e-203 +298 1e-202 +299 1e-201 +300 1e-200 +301 1e-199 +302 1e-198 +303 1e-197 +304 1e-196 +305 1e-195 +306 1e-194 +307 1e-193 +308 1e-192 +309 1e-191 +310 1e-190 +311 1e-189 +312 1e-188 +313 1e-187 +314 1e-186 +315 1e-185 +316 1e-184 +317 1e-183 +318 1e-182 +319 1e-181 +320 1e-180 +321 1e-179 +322 1e-178 +323 1e-177 +324 1e-176 +325 1e-175 +326 1e-174 +327 1e-173 +328 1e-172 +329 1e-171 +330 1e-170 +331 1e-169 +332 1e-168 +333 1e-167 +334 1e-166 +335 1e-165 +336 1e-164 +337 1e-163 +338 1e-162 +339 1e-161 +340 1e-160 +341 1e-159 +342 1e-158 +343 1e-157 +344 1e-156 +345 1e-155 +346 1e-154 +347 1e-153 +348 1e-152 +349 1e-151 +350 1e-150 +351 1e-149 +352 1e-148 +353 1e-147 +354 1e-146 +355 1e-145 +356 1e-144 +357 1e-143 +358 1e-142 +359 1e-141 +360 1e-140 +361 1e-139 +362 1e-138 +363 1e-137 +364 1e-136 +365 1e-135 +366 1e-134 +367 1e-133 +368 1e-132 +369 1e-131 +370 1e-130 +371 1e-129 +372 1e-128 +373 1e-127 +374 1e-126 +375 1e-125 +376 1e-124 +377 1e-123 +378 1e-122 +379 1e-121 +380 1e-120 +381 1e-119 +382 1e-118 +383 1e-117 +384 1e-116 +385 1e-115 +386 1e-114 +387 1e-113 +388 1e-112 +389 1e-111 +390 1e-110 +391 1e-109 +392 1e-108 +393 1e-107 +394 1e-106 +395 1e-105 +396 1e-104 +397 1e-103 +398 1e-102 +399 1e-101 +400 1e-100 +401 1e-99 +402 1e-98 +403 1e-97 +404 1e-96 +405 1e-95 +406 1e-94 +407 1e-93 +408 1e-92 +409 1e-91 +410 1e-90 +411 1e-89 +412 1e-88 +413 1e-87 +414 1e-86 +415 1e-85 +416 1e-84 +417 1e-83 +418 1e-82 +419 1e-81 +420 1e-80 +421 1e-79 +422 1e-78 +423 1e-77 +424 1e-76 +425 1e-75 +426 1e-74 +427 1e-73 +428 1e-72 +429 1e-71 +430 1e-70 +431 1e-69 +432 1e-68 +433 1e-67 +434 1e-66 +435 1e-65 +436 1e-64 +437 1e-63 +438 1e-62 +439 1e-61 +440 1e-60 +441 1e-59 +442 1e-58 +443 1e-57 +444 1e-56 +445 1e-55 +446 1e-54 +447 1e-53 +448 1e-52 +449 1e-51 +450 1e-50 +451 1e-49 +452 1e-48 +453 1e-47 +454 1e-46 +455 1e-45 +456 1e-44 +457 1e-43 +458 1e-42 +459 1e-41 +460 1e-40 +461 1e-39 +462 1e-38 +463 1e-37 +464 1e-36 +465 1e-35 +466 1e-34 +467 1e-33 +468 1e-32 +469 1e-31 +470 1e-30 +471 1e-29 +472 1e-28 +473 1e-27 +474 1e-26 +475 1e-25 +476 1e-24 +477 1e-23 +478 1e-22 +479 1e-21 +480 1e-20 +481 1e-19 +482 1e-18 +483 1e-17 +484 1e-16 +485 1e-15 +486 1e-14 +487 1e-13 +488 1e-12 +489 1e-11 +490 1e-10 +491 1e-9 +492 1e-8 +493 1e-7 +494 0.000001 +495 0.00001 +496 0.0001 +497 0.001 +498 0.01 +499 0.1 +500 1 +501 10 +502 100 +503 1000 +504 10000 +505 100000 +506 1000000 +507 10000000 +508 100000000 +509 1000000000 +510 10000000000 +511 100000000000 +512 1000000000000 +513 10000000000000 +514 100000000000000 +515 1000000000000000 +516 10000000000000000 +517 100000000000000000 +518 1000000000000000000 +519 10000000000000000000 +520 100000000000000000000 +521 1e21 +522 1e22 +523 1e23 +524 1e24 +525 1e25 +526 1e26 +527 1e27 +528 1e28 +529 1e29 +530 1e30 +531 1e31 +532 1e32 +533 1e33 +534 1e34 +535 1e35 +536 1e36 +537 1e37 +538 1e38 +539 1e39 +540 1e40 +541 1e41 +542 1e42 +543 1e43 +544 1e44 +545 1e45 +546 1e46 +547 1e47 +548 1e48 +549 1e49 +550 1e50 +551 1e51 +552 1e52 +553 1e53 +554 1e54 +555 1e55 +556 1e56 +557 1e57 +558 1e58 +559 1e59 +560 1e60 +561 1e61 +562 1e62 +563 1e63 +564 1e64 +565 1e65 +566 1e66 +567 1e67 +568 1e68 +569 1e69 +570 1e70 +571 1e71 +572 1e72 +573 1e73 +574 1e74 +575 1e75 +576 1e76 +577 1e77 +578 1e78 +579 1e79 +580 1e80 +581 1e81 +582 1e82 +583 1e83 +584 1e84 +585 1e85 +586 1e86 +587 1e87 +588 1e88 +589 1e89 +590 1e90 +591 1e91 +592 1e92 +593 1e93 +594 1e94 +595 1e95 +596 1e96 +597 1e97 +598 1e98 +599 1e99 +600 1e100 +601 1e101 +602 1e102 +603 1e103 +604 1e104 +605 1e105 +606 1e106 +607 1e107 +608 1e108 +609 1e109 +610 1e110 +611 1e111 +612 1e112 +613 1e113 +614 1e114 +615 1e115 +616 1e116 +617 1e117 +618 1e118 +619 1e119 +620 1e120 +621 1e121 +622 1e122 +623 1e123 +624 1e124 +625 1e125 +626 1e126 +627 1e127 +628 1e128 +629 1e129 +630 1e130 +631 1e131 +632 1e132 +633 1e133 +634 1e134 +635 1e135 +636 1e136 +637 1e137 +638 1e138 +639 1e139 +640 1e140 +641 1e141 +642 1e142 +643 1e143 +644 1e144 +645 1e145 +646 1e146 +647 1e147 +648 1e148 +649 1e149 +650 1e150 +651 1e151 +652 1e152 +653 1e153 +654 1e154 +655 1e155 +656 1e156 +657 1e157 +658 1e158 +659 1e159 +660 1e160 +661 1e161 +662 1e162 +663 1e163 +664 1e164 +665 1e165 +666 1e166 +667 1e167 +668 1e168 +669 1e169 +670 1e170 +671 1e171 +672 1e172 +673 1e173 +674 1e174 +675 1e175 +676 1e176 +677 1e177 +678 1e178 +679 1e179 +680 1e180 +681 1e181 +682 1e182 +683 1e183 +684 1e184 +685 1e185 +686 1e186 +687 1e187 +688 1e188 +689 1e189 +690 1e190 +691 1e191 +692 1e192 +693 1e193 +694 1e194 +695 1e195 +696 1e196 +697 1e197 +698 1e198 +699 1e199 +700 1e200 +701 1e201 +702 1e202 +703 1e203 +704 1e204 +705 1e205 +706 1e206 +707 1e207 +708 1e208 +709 1e209 +710 1e210 +711 1e211 +712 1e212 +713 1e213 +714 1e214 +715 1e215 +716 1e216 +717 1e217 +718 1e218 +719 1e219 +720 1e220 +721 1e221 +722 1e222 +723 1e223 +724 1e224 +725 1e225 +726 1e226 +727 1e227 +728 1e228 +729 1e229 +730 1e230 +731 1e231 +732 1e232 +733 1e233 +734 1e234 +735 1e235 +736 1e236 +737 1e237 +738 1e238 +739 1e239 +740 1e240 +741 1e241 +742 1e242 +743 1e243 +744 1e244 +745 1e245 +746 1e246 +747 1e247 +748 1e248 +749 1e249 +750 1e250 +751 1e251 +752 1e252 +753 1e253 +754 1e254 +755 1e255 +756 1e256 +757 1e257 +758 1e258 +759 1e259 +760 1e260 +761 1e261 +762 1e262 +763 1e263 +764 1e264 +765 1e265 +766 1e266 +767 1e267 +768 1e268 +769 1e269 +770 1e270 +771 1e271 +772 1e272 +773 1e273 +774 1e274 +775 1e275 +776 1e276 +777 1e277 +778 1e278 +779 1e279 +780 1e280 +781 1e281 +782 1e282 +783 1e283 +784 1e284 +785 1e285 +786 1e286 +787 1e287 +788 1e288 +789 1e289 +790 1e290 +791 1e291 +792 1e292 +793 1e293 +794 1e294 +795 1e295 +796 1e296 +797 1e297 +798 1e298 +799 1e299 +800 1e300 +801 1e301 +802 1e302 +803 1e303 +804 1e304 +805 1e305 +806 1e306 +807 1e307 +808 1e308 +809 inf +810 inf +811 inf +812 inf +813 inf +814 inf +815 inf +816 inf +817 inf +818 inf +819 inf +820 inf +821 inf +822 inf +823 inf +824 inf +825 inf +826 inf +827 inf +828 inf +829 inf +830 inf +831 inf +832 inf +833 inf +834 inf +835 inf +836 inf +837 inf +838 inf +839 inf +840 inf +841 inf +842 inf +843 inf +844 inf +845 inf +846 inf +847 inf +848 inf +849 inf +850 inf +851 inf +852 inf +853 inf +854 inf +855 inf +856 inf +857 inf +858 inf +859 inf +860 inf +861 inf +862 inf +863 inf +864 inf +865 inf +866 inf +867 inf +868 inf +869 inf +870 inf +871 inf +872 inf +873 inf +874 inf +875 inf +876 inf +877 inf +878 inf +879 inf +880 inf +881 inf +882 inf +883 inf +884 inf +885 inf +886 inf +887 inf +888 inf +889 inf +890 inf +891 inf +892 inf +893 inf +894 inf +895 inf +896 inf +897 inf +898 inf +899 inf +900 inf +901 inf +902 inf +903 inf +904 inf +905 inf +906 inf +907 inf +908 inf +909 inf +910 inf +911 inf +912 inf +913 inf +914 inf +915 inf +916 inf +917 inf +918 inf +919 inf +920 inf +921 inf +922 inf +923 inf +924 inf +925 inf +926 inf +927 inf +928 inf +929 inf +930 inf +931 inf +932 inf +933 inf +934 inf +935 inf +936 inf +937 inf +938 inf +939 inf +940 inf +941 inf +942 inf +943 inf +944 inf +945 inf +946 inf +947 inf +948 inf +949 inf +950 inf +951 inf +952 inf +953 inf +954 inf +955 inf +956 inf +957 inf +958 inf +959 inf +960 inf +961 inf +962 inf +963 inf +964 inf +965 inf +966 inf +967 inf +968 inf +969 inf +970 inf +971 inf +972 inf +973 inf +974 inf +975 inf +976 inf +977 inf +978 inf +979 inf +980 inf +981 inf +982 inf +983 inf +984 inf +985 inf +986 inf +987 inf +988 inf +989 inf +990 inf +991 inf +992 inf +993 inf +994 inf +995 inf +996 inf +997 inf +998 inf +999 inf +nan diff --git a/dbms/tests/queries/0_stateless/00534_exp10.sql b/dbms/tests/queries/0_stateless/00534_exp10.sql index df4186d343c..f2836fe0655 100644 --- a/dbms/tests/queries/0_stateless/00534_exp10.sql +++ b/dbms/tests/queries/0_stateless/00534_exp10.sql @@ -1 +1,2 @@ -SELECT number, exp10(number) FROM system.numbers LIMIT 310; +SELECT number, exp10(number - 500) FROM system.numbers LIMIT 1000; +SELECT exp10(nan); diff --git a/libs/libcommon/src/preciseExp10.c b/libs/libcommon/src/preciseExp10.c index d24a7e60241..49c87217e20 100644 --- a/libs/libcommon/src/preciseExp10.c +++ b/libs/libcommon/src/preciseExp10.c @@ -171,47 +171,57 @@ obstacle to adoption, that text has been removed. #include #include +#include double preciseExp10(double x) { + if (isnan(x)) return NAN; + + // ranging between DBL_TRUE_MIN and DBL_MAX. Outsiders are treated as zeros or infinities static const double p10[] - = {1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1, - 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, - 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, - 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, - 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 1e+61, 1e+62, 1e+63, 1e+64, - 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, - 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, - 1e+97, 1e+98, 1e+99, 1e+100, 1e+101, 1e+102, 1e+103, 1e+104, 1e+105, 1e+106, 1e+107, 1e+108, 1e+109, 1e+110, 1e+111, 1e+112, - 1e+113, 1e+114, 1e+115, 1e+116, 1e+117, 1e+118, 1e+119, 1e+120, 1e+121, 1e+122, 1e+123, 1e+124, 1e+125, 1e+126, 1e+127, 1e+128, - 1e+129, 1e+130, 1e+131, 1e+132, 1e+133, 1e+134, 1e+135, 1e+136, 1e+137, 1e+138, 1e+139, 1e+140, 1e+141, 1e+142, 1e+143, 1e+144, - 1e+145, 1e+146, 1e+147, 1e+148, 1e+149, 1e+150, 1e+151, 1e+152, 1e+153, 1e+154, 1e+155, 1e+156, 1e+157, 1e+158, 1e+159, 1e+160, - 1e+161, 1e+162, 1e+163, 1e+164, 1e+165, 1e+166, 1e+167, 1e+168, 1e+169, 1e+170, 1e+171, 1e+172, 1e+173, 1e+174, 1e+175, 1e+176, - 1e+177, 1e+178, 1e+179, 1e+180, 1e+181, 1e+182, 1e+183, 1e+184, 1e+185, 1e+186, 1e+187, 1e+188, 1e+189, 1e+190, 1e+191, 1e+192, - 1e+193, 1e+194, 1e+195, 1e+196, 1e+197, 1e+198, 1e+199, 1e+200, 1e+201, 1e+202, 1e+203, 1e+204, 1e+205, 1e+206, 1e+207, 1e+208, - 1e+209, 1e+210, 1e+211, 1e+212, 1e+213, 1e+214, 1e+215, 1e+216, 1e+217, 1e+218, 1e+219, 1e+220, 1e+221, 1e+222, 1e+223, 1e+224, - 1e+225, 1e+226, 1e+227, 1e+228, 1e+229, 1e+230, 1e+231, 1e+232, 1e+233, 1e+234, 1e+235, 1e+236, 1e+237, 1e+238, 1e+239, 1e+240, - 1e+241, 1e+242, 1e+243, 1e+244, 1e+245, 1e+246, 1e+247, 1e+248, 1e+249, 1e+250, 1e+251, 1e+252, 1e+253, 1e+254, 1e+255, 1e+256, - 1e+257, 1e+258, 1e+259, 1e+260, 1e+261, 1e+262, 1e+263, 1e+264, 1e+265, 1e+266, 1e+267, 1e+268, 1e+269, 1e+270, 1e+271, 1e+272, - 1e+273, 1e+274, 1e+275, 1e+276, 1e+277, 1e+278, 1e+279, 1e+280, 1e+281, 1e+282, 1e+283, 1e+284, 1e+285, 1e+286, 1e+287, 1e+288, - 1e+289, 1e+290, 1e+291, 1e+292, 1e+293, 1e+294, 1e+295, 1e+296, 1e+297, 1e+298, 1e+299, 1e+300, 1e+301, 1e+302, 1e+303, 1e+304, - 1e+305, 1e+306, 1e+307, 1e+308}; + = {1e-323, 1e-322, 1e-321, 1e-320, 1e-319, 1e-318, 1e-317, 1e-316, 1e-315, 1e-314, 1e-313, 1e-312, 1e-311, 1e-310, 1e-309, 1e-308, 1e-307, + 1e-306, 1e-305, 1e-304, 1e-303, 1e-302, 1e-301, 1e-300, 1e-299, 1e-298, 1e-297, 1e-296, 1e-295, 1e-294, 1e-293, 1e-292, 1e-291, 1e-290, + 1e-289, 1e-288, 1e-287, 1e-286, 1e-285, 1e-284, 1e-283, 1e-282, 1e-281, 1e-280, 1e-279, 1e-278, 1e-277, 1e-276, 1e-275, 1e-274, 1e-273, + 1e-272, 1e-271, 1e-270, 1e-269, 1e-268, 1e-267, 1e-266, 1e-265, 1e-264, 1e-263, 1e-262, 1e-261, 1e-260, 1e-259, 1e-258, 1e-257, 1e-256, + 1e-255, 1e-254, 1e-253, 1e-252, 1e-251, 1e-250, 1e-249, 1e-248, 1e-247, 1e-246, 1e-245, 1e-244, 1e-243, 1e-242, 1e-241, 1e-240, 1e-239, + 1e-238, 1e-237, 1e-236, 1e-235, 1e-234, 1e-233, 1e-232, 1e-231, 1e-230, 1e-229, 1e-228, 1e-227, 1e-226, 1e-225, 1e-224, 1e-223, 1e-222, + 1e-221, 1e-220, 1e-219, 1e-218, 1e-217, 1e-216, 1e-215, 1e-214, 1e-213, 1e-212, 1e-211, 1e-210, 1e-209, 1e-208, 1e-207, 1e-206, 1e-205, + 1e-204, 1e-203, 1e-202, 1e-201, 1e-200, 1e-199, 1e-198, 1e-197, 1e-196, 1e-195, 1e-194, 1e-193, 1e-192, 1e-191, 1e-190, 1e-189, 1e-188, + 1e-187, 1e-186, 1e-185, 1e-184, 1e-183, 1e-182, 1e-181, 1e-180, 1e-179, 1e-178, 1e-177, 1e-176, 1e-175, 1e-174, 1e-173, 1e-172, 1e-171, + 1e-170, 1e-169, 1e-168, 1e-167, 1e-166, 1e-165, 1e-164, 1e-163, 1e-162, 1e-161, 1e-160, 1e-159, 1e-158, 1e-157, 1e-156, 1e-155, 1e-154, + 1e-153, 1e-152, 1e-151, 1e-150, 1e-149, 1e-148, 1e-147, 1e-146, 1e-145, 1e-144, 1e-143, 1e-142, 1e-141, 1e-140, 1e-139, 1e-138, 1e-137, + 1e-136, 1e-135, 1e-134, 1e-133, 1e-132, 1e-131, 1e-130, 1e-129, 1e-128, 1e-127, 1e-126, 1e-125, 1e-124, 1e-123, 1e-122, 1e-121, 1e-120, + 1e-119, 1e-118, 1e-117, 1e-116, 1e-115, 1e-114, 1e-113, 1e-112, 1e-111, 1e-110, 1e-109, 1e-108, 1e-107, 1e-106, 1e-105, 1e-104, 1e-103, + 1e-102, 1e-101, 1e-100, 1e-99, 1e-98, 1e-97, 1e-96, 1e-95, 1e-94, 1e-93, 1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, + 1e-85, 1e-84, 1e-83, 1e-82, 1e-81, 1e-80, 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71, 1e-70, 1e-69, + 1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 1e-59, 1e-58, 1e-57, 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, + 1e-51, 1e-50, 1e-49, 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41, 1e-40, 1e-39, 1e-38, 1e-37, 1e-36, 1e-35, + 1e-34, 1e-33, 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23, 1e-22, 1e-21, 1e-20, 1e-19, 1e-18, + 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, + 1e0, 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, + 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, + 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, + 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, + 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 1e+81, 1e+82, 1e+83, 1e+84, + 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 1e+101, + 1e+102, 1e+103, 1e+104, 1e+105, 1e+106, 1e+107, 1e+108, 1e+109, 1e+110, 1e+111, 1e+112, 1e+113, 1e+114, 1e+115, 1e+116, 1e+117, 1e+118, + 1e+119, 1e+120, 1e+121, 1e+122, 1e+123, 1e+124, 1e+125, 1e+126, 1e+127, 1e+128, 1e+129, 1e+130, 1e+131, 1e+132, 1e+133, 1e+134, 1e+135, + 1e+136, 1e+137, 1e+138, 1e+139, 1e+140, 1e+141, 1e+142, 1e+143, 1e+144, 1e+145, 1e+146, 1e+147, 1e+148, 1e+149, 1e+150, 1e+151, 1e+152, + 1e+153, 1e+154, 1e+155, 1e+156, 1e+157, 1e+158, 1e+159, 1e+160, 1e+161, 1e+162, 1e+163, 1e+164, 1e+165, 1e+166, 1e+167, 1e+168, 1e+169, + 1e+170, 1e+171, 1e+172, 1e+173, 1e+174, 1e+175, 1e+176, 1e+177, 1e+178, 1e+179, 1e+180, 1e+181, 1e+182, 1e+183, 1e+184, 1e+185, 1e+186, + 1e+187, 1e+188, 1e+189, 1e+190, 1e+191, 1e+192, 1e+193, 1e+194, 1e+195, 1e+196, 1e+197, 1e+198, 1e+199, 1e+200, 1e+201, 1e+202, 1e+203, + 1e+204, 1e+205, 1e+206, 1e+207, 1e+208, 1e+209, 1e+210, 1e+211, 1e+212, 1e+213, 1e+214, 1e+215, 1e+216, 1e+217, 1e+218, 1e+219, 1e+220, + 1e+221, 1e+222, 1e+223, 1e+224, 1e+225, 1e+226, 1e+227, 1e+228, 1e+229, 1e+230, 1e+231, 1e+232, 1e+233, 1e+234, 1e+235, 1e+236, 1e+237, + 1e+238, 1e+239, 1e+240, 1e+241, 1e+242, 1e+243, 1e+244, 1e+245, 1e+246, 1e+247, 1e+248, 1e+249, 1e+250, 1e+251, 1e+252, 1e+253, 1e+254, + 1e+255, 1e+256, 1e+257, 1e+258, 1e+259, 1e+260, 1e+261, 1e+262, 1e+263, 1e+264, 1e+265, 1e+266, 1e+267, 1e+268, 1e+269, 1e+270, 1e+271, + 1e+272, 1e+273, 1e+274, 1e+275, 1e+276, 1e+277, 1e+278, 1e+279, 1e+280, 1e+281, 1e+282, 1e+283, 1e+284, 1e+285, 1e+286, 1e+287, 1e+288, + 1e+289, 1e+290, 1e+291, 1e+292, 1e+293, 1e+294, 1e+295, 1e+296, 1e+297, 1e+298, 1e+299, 1e+300, 1e+301, 1e+302, 1e+303, 1e+304, 1e+305, + 1e+306, 1e+307, 1e+308}; double n, y = modf(x, &n); - if (n > 308) - return x > 0 ? INFINITY : -INFINITY; - if (!y) - return p10[(int)n + 15]; + if (n > 308) return INFINITY; + if (n < -323) return 0; - union - { - double f; - uint64_t i; - } u = {n}; - if ((u.i >> 52 & 0x7ff) < 0x3ff + 4) - { - y = exp2(3.32192809488736234787031942948939 * y); - return y * p10[(int)n + 15]; - } - return pow(10.0, x); + // Using lookup table based formula to get accurate results for integer arguments. + return exp2(3.32192809488736234787031942948939 * y) * p10[(int)n + 323]; }