Beginner Casting Question

I was going to use math.h on my numbers in my random number generator. It seems that I can only use math.h functions on doubles. So:

I am trying to give the "value" the value of "currentValue" or at least part of the number to be transmitted. I work with a random number generator, so I don’t care if the whole number is passed. I need only part of his work.

I have at some point:

int currentValue;
double value;

** Using a code not shown, their values ​​are set. **

Later I need a piece of value to go to currentValue.

currentValue = value 

I tried:

currentValue = static_cast<int>value; 

Any help would be appreciated.

Thanks for the help. The problem is resolved.

+3
source share
2 answers

you forgot your partners:

currentValue = static_cast<int>(value); 
+2

, . , - .

+2

Source: https://habr.com/ru/post/1789666/


All Articles