paul4463 Posted January 3, 2022 Share Posted January 3, 2022 Hi I'm trying to convert bitcoin back to pound sterling. if bitcoin price is 34992.34 and i invest £100 i get 0.0028653401860809 bitcoin this is correct, so how do I output the answere in pound sterling , in other words how do i convert 0.0028653401860809 too pound sterling. not sure what you devide or multiply any help please. Quote Link to comment https://forums.phpfreaks.com/topic/314381-php-convert-one-price-to-another/ Share on other sites More sharing options...
gw1500se Posted January 3, 2022 Share Posted January 3, 2022 Not really a PHP question but how can that number be correct? You seem to be dividing GBP by USD. You need to convert bitcoin to GBP before you divide. You need to multiply 43992.43 USD by the current exchange rate (presently £0.74169) then divide £100 by that. However, since the exchange rate is constantly changing you need to look that number up somewhere when you do the conversion. Same with bitcoin which is currently $47,090.04 US. Quote Link to comment https://forums.phpfreaks.com/topic/314381-php-convert-one-price-to-another/#findComment-1593139 Share on other sites More sharing options...
requinix Posted January 3, 2022 Share Posted January 3, 2022 No offense but this is a very basic math question. https://www.google.com/search?q=how+to+convert+numbers+between+different+units Quote Link to comment https://forums.phpfreaks.com/topic/314381-php-convert-one-price-to-another/#findComment-1593140 Share on other sites More sharing options...
paul4463 Posted January 3, 2022 Author Share Posted January 3, 2022 Yep a math question I finally worked it out from your link, now I can re write my php code.thanks Quote Link to comment https://forums.phpfreaks.com/topic/314381-php-convert-one-price-to-another/#findComment-1593144 Share on other sites More sharing options...
NotionCommotion Posted January 3, 2022 Share Posted January 3, 2022 There are also some existing libraries to meet this need: https://github.com/brick/money https://github.com/moneyphp/money Quote Link to comment https://forums.phpfreaks.com/topic/314381-php-convert-one-price-to-another/#findComment-1593146 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.