Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: COBRAS on April 16, 2022, 06:52:02 PM



Title: How to limit the number of decimal numbers obtained during calculation and used?
Post by: COBRAS on April 16, 2022, 06:52:02 PM
How to limit the number of decimal numbers obtained during calculation and used in calculations ?

Good day.

Then I use keymath and modmath and devide for deviding for example 777 / 999 = 0.77777777777777777....7 inf. modmath and keymath genererate result not with minimum needed float numbers 0.77777777777777777(This will be named X) * 999 = 777.0, but with maximum nposible float number - 0.77777777777777777777777777777777777777777777777777777777777777777777777777777 7777777777777777777777777777777777777777777777777777777777777777 ........7 (this will be named Y) * 999 = 777.0 and private / publick keys for X and Y are different !!!

How to use in calculus editable floats count in result ?


0.77777777777777777 * 999 = 777


0.77777777777777777777777777777777777777777777777777777777777777777777777777777 7777777777777777777777777777777777777777777777777777777777777777 * 999 = 777


0.77777777777777777777777777777777777777777777777777777777777777777777777777777 7777777777777777777777777777777777777777777777777777777777777777 - THIS IS TOO MANY, HOW TO MODIFY MODMATH AND KEYMATH USE THIS - 0.77777777777777777
 RESULT OF THEIR CALCULATION

help plesse ?



Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: n0nce on April 16, 2022, 07:53:35 PM
Actually 777/999 is just 7/9. There is no non-infinite decimal representation of it.

If you plug it into a calculator, due to rounding, it gives the same result if you multiply 0.7777*999 or 0.777777777777777*999, but to be exact, both shouldn't give you the exact number 777.

I don't know modmath / keymath, but depending on what you have to do and what tools it gives you, you might be able to just round to X decimal places. Or calculate with proper decimal fractions instead of decimal numbers.


Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: COBRAS on April 16, 2022, 08:31:08 PM
Actually 777/999 is just 7/9. There is no non-infinite decimal representation of it.

If you plug it into a calculator, due to rounding, it gives the same result if you multiply 0.7777*999 or 0.777777777777777*999, but to be exact, both shouldn't give you the exact number 777.

I don't know modmath / keymath, but depending on what you have to do and what tools it gives you, you might be able to just round to X decimal places. Or calculate with proper decimal fractions instead of decimal numbers.

999 is a scalar, 777 is a publick key, how to get first 20 digits of 0.77777777....inf ? What is posible to do somethink with 0.77777777....inf pubkey, to get pubkey only from 20 first digits of 0.77777777....inf ?

Thx.


Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: n0nce on April 17, 2022, 12:58:51 AM
Actually 777/999 is just 7/9. There is no non-infinite decimal representation of it.

If you plug it into a calculator, due to rounding, it gives the same result if you multiply 0.7777*999 or 0.777777777777777*999, but to be exact, both shouldn't give you the exact number 777.

I don't know modmath / keymath, but depending on what you have to do and what tools it gives you, you might be able to just round to X decimal places. Or calculate with proper decimal fractions instead of decimal numbers.

999 is a scalar, 777 is a publick key, how to get first 20 digits of 0.77777777....inf ? What is posible to do somethink with 0.77777777....inf pubkey, to get pubkey only from 20 first digits of 0.77777777....inf ?
Again, I don't know if your software / programming language / whatever allows to truncate or round to a certain amount of decimal places, but be aware that if you do, the result becomes mathematically wrong / inaccurate. You do need all the infinite decimal places to accurately describe a division of 9 (and other periodic numbers) if you don't want to use a proper decimal fraction (like '7 over 9').


Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: COBRAS on April 17, 2022, 03:26:21 AM
Example: 0x35c0d7234df7deb0f20cf7062444) / 2**110) ) * 10000000000000000 = 8398950428744437 (does someone uderstand why  I need this and how to use it  ???

This is not mod calculus.

(0.8398950428744437*2**110) - 0x35c0d7234df7deb0f20cf7062444 = 0

So, if someone show how to hack tjis shit, it can be good !

So, Lets power on our brains !!!


Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: garlonicon on April 17, 2022, 04:10:34 AM
You are getting implementation-dependent garbage numbers. It is hard to say how to get those numbers, because without code, we have no idea, where you made a mistake in your own code.

But I guess it is related to float precision. Maybe check basic things, for example that adding 0.1 ten times gives you exactly 1.


Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: pooya87 on April 17, 2022, 04:21:55 AM
Why do you even have decimals? You mention scalar and publickey and this is a bitcoin board so you must be working with modular arithmetic where you should only deal with integers (numbers without decimals or fractions).


Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: COBRAS on April 17, 2022, 05:10:26 AM
Why do you even have decimals? You mention scalar and publickey and this is a bitcoin board so you must be working with modular arithmetic where you should only deal with integers (numbers without decimals or fractions).

But, secp256  curve think anower, divide 68140381134624198284233778684484 this priv to 1298074214633706907132624082305024 you get float coded in hex !

You can convert decimail geted in not mod calc and get back privkey.

And publick key math operation and pablick key are same, is simple use then you have all pub's or priv's, privs or pabs and vs.You can multiply privs, and get pubs from result * base poit, or use pab and multiply to priv ang get pubkey what will be same.


Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: COBRAS on April 17, 2022, 05:11:58 AM
You are getting implementation-dependent garbage numbers. It is hard to say how to get those numbers, because without code, we have no idea, where you made a mistake in your own code.

But I guess it is related to float precision. Maybe check basic things, for example that adding 0.1 ten times gives you exactly 1.

68140381134624198284233778684484 this is a priv puzzle 110 in dec, this is a 2^110 range - 1298074214633706907132624082305024.



Title: Re: How to limit the number of decimal numbers obtained during calculation and used?
Post by: ABCbits on April 17, 2022, 11:18:49 AM
You are getting implementation-dependent garbage numbers. It is hard to say how to get those numbers, because without code, we have no idea, where you made a mistake in your own code.

But I guess it is related to float precision. Maybe check basic things, for example that adding 0.1 ten times gives you exactly 1.

There's even website about it at https://0.30000000000000004.com/ (https://0.30000000000000004.com/).

I don't know modmath / keymath

OP might be referring to this repository, https://github.com/albertobsd/ecctools (https://github.com/albertobsd/ecctools).