How to change int to float??

i try to do some mathematics calculation on arduino ... but i dint get the same answer as i calculated in calculator...
in this coding ... i expected to get the power = 3.124 x 240x 0.387 = 290.16... but the serial monitor show diff answer.... pls help me ... thank you

void setup() {
Serial.begin(9600); 

int Current= 3124;
int Voltage= 2400;
int Pf = 387;
 
float current = float (Current);
current = current/1000; 
Serial.println (current);
float voltage = float (Voltage);
voltage = voltage/10; 
Serial.println (voltage);
float pf = float (Pf);
Serial.println (pf);
pf = pf/1000; 
Serial.println (pf);



float power = current *voltage* pf; 
Serial.println (power);
}


void loop() {
  // put your main code here, to run repeatedly:

}

but the serial monitor show diff answer

What would that answer be?

How to change int to float?

You don't. You create a new float variable (or reuse an already existing float variable) and simply set it equal to the integer variable.

int Pf = 387;
float pf = Pf;

the answer 290.16 ...
i found that is do the multiple like 3.1 x 240 x 0.39 ...
it din take the V as 3.12...

i expected to get the power = 3.124 x 240x 0.387 = 290.16...

It is clear that your power quantity should be : 3.124 x 240x 0.387 = 290.157120, and the calculating machine must do it correctly?

If you want to play around or doing some exercises for yourself that is the different story; otherwise, follow the straight forward logic of programming:

void setup() {
Serial.begin(9600); 

float Current = 3.124;
int Voltage = 240;
float Pf = 0.387;

float power = Current*Voltage*Pf;  //at least one quantity should be in float; you have here two
Serial.println (power, 6);  //290.157104 error : 0.00000016%
}

void loop() 
{

}

My handheld Calculator (oppo) makes exactly 290.157120; why is MEGA making 290.157104? Arduino DUE is making exactly 290.157120; in DUE, I have declared double instead of float. If you declare float in DUE, you will also get the same value as 290.157104. This is related with single precision (binary32) and double precision (binary64) floating point number representation conventions.

Well...compare

int current =1005;

current = (float)current / 10;

and

int current = 1005;
float answer = 0;
answer = (float)current/10;

(float) would make current behave as a float in your operation if it was declared as an int...but in this case it won’t work as you’re operating on itself...so you end up storing it back as an int. as said, you need a new variable.

No, there's two variables for current in the original code. One has a capital "C".