C++ arithmetic calcs

I am running a simple arithmetic operation in a charting software sierra chart: Eg

float x = 1.2f;
float y = 1.0f; //this variable is set as "float" type by the charting software automatically
result = x - y;
float z = 0.2f;

I have a preprogrammed output command from the charting software, but a desired result of this simple calculation fails to register all the time Eg

if (result <= z){alert;}

Because it works sometimes, I am wondering if there is a challenge with the float point types, with the fixed variable y, or with the preprogrammed alert output itself. Certainly I can only expect comments regarding the calculation and variable type.

thx for the help!
Last edited on
What is the type of 'result'?

https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
writes:
We’ve finally reached the point in this series that I’ve been waiting for. In this post I am going to share the most crucial piece of floating-point math knowledge that I have. Here it is:

[Floating-point] math is hard.

float

I am now fearful that 2-1=1 only sometimes in this game. How true!

Thx for the help. I have made the necessary adjustments and it works fine now.
Last edited on
Topic archived. No new replies allowed.