Litecoin Bitcoin how divide uint256 target value on difficulty in C

0 votes

I get unit256 class from litecoin wallet source, but this class dont have divide operator. So i convert uint256 to double which have implemintation in uint256 class

double getdouble() const
{
   double ret = 0.0;
   double fact = 1.0;
   for (int i = 0; i < WIDTH; i++) {
       ret += fact * pn[i];
       fact *= 4294967296.0;
   }
   return ret;
}
But now i need convert this huge double to hex string. This string will be represent target for miner, as far i understand. Or i need this double variable converts back to uint256 and thet get hex from it. 
Sep 12, 2018 in Blockchain by slayer
• 29,370 points
999 views

1 answer to this question.

0 votes

This is the solution:

void setdouble(double val)
{
    double ret = val;
    double fact = 1.0;
    for (int i = 0; i < WIDTH; i++) {
        double a = ret / fact;
        pn[i] =  (uint32_t)a;
        fact *= 4294967296.0;
    }
}
answered Sep 12, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
0 answers

How to get Bitcoin value for corresponding USD value in ASP.NET C#?

I want to get the Bitcoin value ...READ MORE

Mar 1, 2022 in Blockchain by Soham
• 9,710 points
828 views
+1 vote
2 answers

How to return value from a chaincode in Hyperledger Fabric?

Hyperledger Fabric supports only 2 types of ...READ MORE

answered Jun 13, 2018 in Blockchain by Perry
• 17,100 points
3,004 views
0 votes
1 answer

How are unique public address generated in bitcoin?

In brief, the public addresses are generated ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,370 points
809 views
0 votes
1 answer
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,461 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,947 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,472 views
0 votes
1 answer

How i can use nodejs to watch transactions in bitcoin network?

you can use  const Socket = require('blockchain.info/Socket'); const mySocket ...READ MORE

answered Jul 9, 2018 in Blockchain by digger
• 26,740 points
1,310 views
0 votes
1 answer

How to get current value of bitcoin?

You can use json_decode to transform it ...READ MORE

answered Aug 20, 2018 in Blockchain by digger
• 26,740 points
846 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP