Tonic-_- Posted August 26, 2011 Share Posted August 26, 2011 Hmm... Alright, I did this a few months ago, I reloaded the OS on my VPS and now I'm getting issues. I'm converting a value like 110000120bfd99a from hex to decimal, it's suppose to return 76561198509709722, but instead, it's returning 7.656119850971E+16 Any ideas how to fix this? It's really starting to annoy me.. I use hexdec($value); Like I said, it worked before I reloaded my OS now it just won't work :\ Link to comment https://forums.phpfreaks.com/topic/245779-problem-with-hexdec/ Share on other sites More sharing options...
Pikachu2000 Posted August 26, 2011 Share Posted August 26, 2011 That number exceeds the maximum integer value for a 32 bit OS, so it's being represented exponentially. you could use number_format() to change the way it's displayed. echo number_format(hexdec('110000120bfd99a'), 0, '', ''); Link to comment https://forums.phpfreaks.com/topic/245779-problem-with-hexdec/#findComment-1262405 Share on other sites More sharing options...
Tonic-_- Posted August 26, 2011 Author Share Posted August 26, 2011 That number exceeds the maximum integer value for a 32 bit OS, so it's being represented exponentially. you could use number_format() to change the way it's displayed. echo number_format(hexdec('110000120bfd99a'), 0, '', ''); Ahh, I kind of thought it may have to be with the servers OS, I went from a 64-bit OS to a 32-bit OS. I tried what you said, sadly it didn't return exactly what I wanted. Suppose I'll just have to reload it with 64-bit again or maybe make a API on a 64-bit OS to call it, thanks anyways :3 Link to comment https://forums.phpfreaks.com/topic/245779-problem-with-hexdec/#findComment-1262434 Share on other sites More sharing options...
Pikachu2000 Posted August 26, 2011 Share Posted August 26, 2011 It returns the number in the format you showed in the OP. Is that not the format you actually want? Link to comment https://forums.phpfreaks.com/topic/245779-problem-with-hexdec/#findComment-1262435 Share on other sites More sharing options...
Tonic-_- Posted August 26, 2011 Author Share Posted August 26, 2011 It returns 76561198509709728 when it was suppose to return 76561198509709722 only the last digit is incorrect :3, tested it on a few other strings and it seems to only be off by a few, but the amount it's off by is not always the same. Link to comment https://forums.phpfreaks.com/topic/245779-problem-with-hexdec/#findComment-1262446 Share on other sites More sharing options...
Pikachu2000 Posted August 26, 2011 Share Posted August 26, 2011 Oh, probably a floating point conversion error causing it to do that would be my best guess. Link to comment https://forums.phpfreaks.com/topic/245779-problem-with-hexdec/#findComment-1262448 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.