facha Posted May 5, 2016 Share Posted May 5, 2016 Hello I have this code: <?php $xtile = floor(((37.739658 + 180) / 360) * pow(2, 3200)); echo $xtile; i need to echo the value of $xtile but it always returns INF, i can do this in JavaScript but for some reason im not being able to do this via PHP Thanks Quote Link to comment https://forums.phpfreaks.com/topic/301167-problem-with-numbers/ Share on other sites More sharing options...
requinix Posted May 6, 2016 Share Posted May 6, 2016 You can't do that in Javascript: pow(2, 3200) is 19769064789825639936542264398379633403153906826257738289182657101583406010939511 26756295848974613063099294244703164628428967968057547050608904859234600159014229 32910219510157408105706166194810688480032112981869391460884528166146233381432654 43897411640093676025481038827241878315873949544631831377356573070196373591692908 34318700453890617892714561362370427388384101316010134426924662084888461376218489 65379424299905389115138246588848200330008567611017346799700349415983009427194750 60249742719534147060380682101703389616632028392036411208652632922487186929249151 89291455200665479606951612257868495299167071771306894428954788679149900427954823 30039364000764939774210663557382842575273030537523272133980387188929928113420821 11313410011356054468094774099792796272131886101128679295697894926404657366339250 65052540962862027736312499143902692033755536952046162410311395501619568814547777 27103125924797325086658311685361590835288130558729717818314538874578129700223818 1376Maybe that part is a typo? 1 Quote Link to comment https://forums.phpfreaks.com/topic/301167-problem-with-numbers/#findComment-1532876 Share on other sites More sharing options...
Barand Posted May 6, 2016 Share Posted May 6, 2016 (edited) You will need bcmath library to do it in php $x = (37.739658 + 180) / 360; $xtile = bcmul($x, bcpow(2,3200), 0); echo $xtile; giving 1195697057310125832371140711633564800180786038375872658403318152095581962252386539444192207669999 4207959832759648879404409081079451419565470276854106090269574245270335849760856131899854524127642 7324964717602398404052293164714217486036187584311373189602241206357140904647698252514706029297316 9903133287668377476541891044796672937490793296463688346149780776864963757079645918149252840838799 6339961375594565001261410980667493879041252370996632123897458999476098059823194577935019128254436 6030860257855571048100823754022659657970273909948380147791379123616894368709592470891060276597854 8271325003793426334823472642940015323876156075156400473671902771191374590935488622949583607624016 9866685125773087182548515916284210254502245372017267188638444500873324474387826190977942219959682 1489421060559178529999373973134461270691821511678419523717048252856218976237026885921242952914162 8090268067144283996195298887019205345498122356598595705782092401101204314360135493325755304 Edited May 6, 2016 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/301167-problem-with-numbers/#findComment-1532893 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.