mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
Modify comments about the precision
This commit is contained in:
committed by
Christian Decker
parent
b28d71a9a5
commit
c20e859f05
@@ -429,13 +429,10 @@ static void json_pay_getroute_reply(struct subd *gossip UNUSED,
|
|||||||
|
|
||||||
msatoshi_sent = route[0].amount;
|
msatoshi_sent = route[0].amount;
|
||||||
fee = msatoshi_sent - pay->msatoshi;
|
fee = msatoshi_sent - pay->msatoshi;
|
||||||
/* FIXME: IEEE Double-precision floating point has only 53 bits
|
/* Casting u64 to double will lose some precision. The loss of precision
|
||||||
* of precision. Total satoshis that can ever be created is
|
* in feepercent will be like 3.0000..(some dots)..1 % - 3.0 %.
|
||||||
* slightly less than 2100000000000000. Total msatoshis that
|
* That loss will not be representable in double. So, it's Okay to
|
||||||
* can ever be created is 1000 times that or
|
* cast u64 to double for feepercent calculation. */
|
||||||
* 2100000000000000000, requiring 60.865 bits of precision,
|
|
||||||
* and thus losing precision in the below. Currently, OK, as,
|
|
||||||
* payments are limited to 4294967295 msatoshi. */
|
|
||||||
feepercent = ((double) fee) * 100.0 / ((double) pay->msatoshi);
|
feepercent = ((double) fee) * 100.0 / ((double) pay->msatoshi);
|
||||||
fee_too_high = (feepercent > pay->maxfeepercent);
|
fee_too_high = (feepercent > pay->maxfeepercent);
|
||||||
delay_too_high = (route[0].delay > pay->maxdelay);
|
delay_too_high = (route[0].delay > pay->maxdelay);
|
||||||
|
|||||||
Reference in New Issue
Block a user