VEX cast float to integer

   7503   2   0
User Avatar
Member
22 posts
Joined: Oct. 2021
Offline
Hi everyone. I'm just wondering why the value of this VEX function is not correct? I think it's because of the integer value from the variable A, but I already tried to use 1.0*... and the result is still incorrect. The correct values are variables "A", "a", and "R". But for variables "l" and "addDist" is wrong. It shows a warning that said "Implicit cast from float to int. Use explicit cast instead", but I'm not quite sure what that means. Can someone please help me check which part I'm wrong at? I'm aiming to find the length of the green line. Thanks in advance!

Attachments:
Screenshot 2022-06-13 022021.png (608.1 KB)

User Avatar
Member
355 posts
Joined: Nov. 2013
Offline
^ is bitwise XOR operator. I think you mean "float l = sqrt(R*R - a*a / 4.0)"

also, instead of chs in backticks it would be better to use chf() for float parameters and chi() for int parameters.
User Avatar
Member
22 posts
Joined: Oct. 2021
Offline
antc
^ is bitwise XOR operator. I think you mean "float l = sqrt(R*R - a*a / 4.0)"

also, instead of chs in backticks it would be better to use chf() for float parameters and chi() for int parameters.

Hi antc. Thank you for your answer. I totally forgot that we need to use "pow()" if we want to do a power of calculation. And yes, I use your code and the value is now correct.
  • Quick Links