Bitcoin Forum
May 25, 2024, 02:16:38 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Bitcoin Technical Support / Re: Difficulty with Difficulty on: May 31, 2018, 01:20:07 PM
Now, once I have figured how to handle the very large numbers in PHP I should be in good shape.
Can you use bc (see PHP: BC Math?

Code:
echo 26959535291011309493156476344723991336010898738574164086137773096960 / 4306949573981.513 | bc
6259542822111301937734005144785305510317670759324150579



The actual arithmetic (floating point) was not too much of a problem, the challenge was converting the result to hex. I managed to find a bit of code on the web which did the job a treat.

https://stackoverflow.com/questions/5301034/how-to-generate-random-64-bit-value-as-decimal-string-in-php/5302533#5302533

(Section 2 of the above link.)
2  Bitcoin / Bitcoin Technical Support / Re: Difficulty with Difficulty on: May 30, 2018, 02:49:50 PM
Excellent response. Thank you. I found that the digits to the right of the decimal point in the value returned from Getdifficulty can safely be ignored.

Now, once I have figured how to handle the very large numbers in PHP I should be in good shape.
3  Bitcoin / Bitcoin Technical Support / Re: Difficulty with Difficulty on: May 30, 2018, 09:27:36 AM
First, you need to convert your decimal number into hex.
Then you will have a packed represantation of the target.

Thanks for the quick reply. A problem I have is how to interpret the number returned, for example

4306949573981.513

What does the period represent? Is it simply a decimal point? If so, do I ignore the digits to the right of the decimal point when converting the number to hex?

Does the period represent a floating point number?
4  Bitcoin / Bitcoin Technical Support / Difficulty with Difficulty on: May 30, 2018, 08:44:40 AM
I am using Bitcoin Core 64-bit, 0.16.0 (on Windows 7) and I am playing around with PHP to access Bitcoin client with RPC.

It's all going quite well but I have hit a bit of a roadblock trying to process Difficulty.

The "GetDifficulty" RPC call returns a value like
4306949573981.513


How do I transform this value into an actual target like 0x1b0404cb ?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!