Position: Home page » Equipment » Other types of mining POW functions

Other types of mining POW functions

Publish: 2021-05-21 00:28:07
1. double Factorial(double x, unsigned int n)/(x-1)*(x-2).....
{
double sum = 1;
br/>if (n <
return 0;< br/>for (unsigned int i = 1; i <= = n; i++)
sum *= x--;< <
}
double pow_1(double x, int n)/ > {
double sum = 1;
br/>for (int i = 1; i <= = n; i++)
sum *= x;< < br />}
double pow_2(double x, double a)///first channel of calculation from Thailand
{
int MAX = 100; // Grade
double sum = 1, k1, k2;< br/>if (x > 2)/x is larger than 2 required (x divided 1) a value
{
return 1/pow(1/x, a);
}
if (x == 0)
{
return 0;
} x--;< br/>for (int i = 1; i < MAX; i++)//Television request and
{
k1 = pow_1(x, i);
k2 = Factorial(a, i);< br/>sum += k1 * k2 / Factorial(i, i);<
}
return sum;< br/>}

int main()
{

2.

Pow() function is used to find the power of y of X. x, y and the value of function are all double type. Its prototype is double pow (double x, double y)

the example code is as follows:

? Include & lt; stdio.h>

#include< math.h>

void main()

{

double x = 2, y = 10;

printf("% f ", pow(x, y));

return 0;

}

extended data :

when calling POW function, it may cause error:

if base x is negative and Index Y is not an integer, it will cause domain error

if both the base X and the index y are 0, the domain error? Error, or maybe not; It's about the implementation of the library

if the base x is 0 and the Index Y is negative, it may lead to? Domain error or pole error, or maybe not; It's about the implementation of the library

if the return value RET is too large or too small, it will cause range error

error code:

if domain error occurs, the global variable errno will be set to Edom

If pole error or range error occurs, the global variable errno will be set to ERANGE

3.

POW function:
mathematical function in C / C +

The

pow() function is used to calculate the power of y of X. the values of X, y and the function are all double

pow() is used to calculate the power of Y with X as the base, and then return the result. Let RET be the return value, then RET = XY

may cause errors:

  1. if the base x is negative and the exponent y is not an integer, it will cause domain error

  2. if both base X and Index Y are 0, domain error may or may not occur; It's about the implementation of the library

  3. if the base x is 0 and the Index Y is negative, domain error or pole error may or may not be caused; It's about the implementation of the library

  4. if the return value RET is too large or too small, it will cause range error

  5. < / OL >

    error code:

    1. if domain error occurs, the global variable errno will be set to Edom

    2. If pole error or range error occurs, the global variable errno will be set to ERANGE

    3. < / OL >

      {rrrrrrr}

      development materials:

      prototype: in TC2.0, the prototype is external float pool (float x, float y), In VC6.0, the prototype is double pow (double x, double y)

      header file: math.h/cmath (in C + +)

      function: calculate the Y power of X

      return value: X cannot be negative and Y is a decimal, or X is 0 and Y is less than or equal to 0, return the result of power exponent

      return type: double, int, float will give warning! Network -- POW function

4.

Usage:

? Include & lt; math.h>// This one. In fact, it's OK to have none

double x,y,z;// You can assign values on demand 1

z=pow(x,y);

printf(“%lf 2”,z3);// You can adjust it according to how many digits you want to output, for example, one decimal%. 1lf

(1) when "X" and "Y" are defined as int, note 3 also holds

(2) when defining "Z" as int, you can also change the type of printf to "d"

[2]% lf

because the type of Z is now double, so use% LF. If you use% D, the total output is zero

[3] "Z"

it's OK to change "Z" into "pow (x, y)" here

extended data

type conversion problems for pow:

when "Z" is defined as int, or the type of printf is changed to% D, a conversion problem from double to int occurs. Here, the conversion process is very rough, will directly remove the decimal, resulting in errors

in order to avoid this problem and output integers, we can take the following steps:

1) printf (& quot;%) 0lf", pow(x,y));

2 printf("% d",( int)(pow(x,y)+0.5));// Artificial rounding

5. Parameter types should be strictly consistent, unless they can be implicitly converted
for example, int and float types can be implicitly converted to double types, and because they are upward extended, they will not cause any sequelae
function value types have never heard that you should say the return value of a function, which depends on the return value type of the function, For example, the return value of pow here is also double type
-- supplement
the pow function is a library function, and the parameter type has been determined, so you can't change it
you can pass in int type, but when it is actually passed in, it is converted once, and when it is passed out, it is still double type
you can change it to int type again (you don't need to consider this very often, Because 5.00000 and 5 won't make any difference to your later operation)
-- add again
Yes, the return value type of the function won't change because of the change of the value you pass in, unless it's a function template of C + +, POW is just an ordinary function
6. Because POW is a power function, and the square root is equivalent to the power of the exponent, which is the power of the fraction. For example, the 1 / 2 power of 2 is equivalent to the root 2, so the second parameter must be the fraction. What you call 1.0/n is actually the fraction, which completes the square root n
7. Type: extern float pow(float x, float y);< br />
Use law: #include < math.h > < br/>
Functions: yth of calculator 24130;



indicate: x should be larger than 0, return 24130;

Example:

/ / / / / / pow.c






& #include < math.h > < br/> & #include < Conio.h > < br/> < void main()


< printf(" 4^5=%f ", Pow(4.5.);< br/> < getchar();< br/ > }

Relevant communications: pow10
8. scanf("% lf",& x);< br />
scanf("% lf",& y);

the format specifier corresponding to double type is% LF, note that it is lowercase letter L
9. Dev C++ 4.9.9.2

#include<stdio.h>
#include <math.h>

int main ( void )
{
double a = 2;
double x;
x = pow ( 10, a );
printf ( "%lf\n", x );
system ( "pause" );
return 0;
}

无论是断点调试还是直接查看程序运行结果, 都是100.000000
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750