Double vs FLOAT - unclear MathFloor error - page 3

 

Note that the normalised number when output to the logbook using Print() may contain more decimal places than you expect. For example,

then in the comment the same

 
fxsaber:
#define TOSTRING(A) #A + " = " + (string)(A) + " "

void OnStart()
{
  double Price1 = 105143;
  double Price2 = Price1 - 1 e-11;

  Print(TOSTRING(Price1) + TOSTRING(MathFloor(Price1)) +
        TOSTRING(Price2) + TOSTRING(MathFloor(Price2)) +
        TOSTRING(Price1 > Price2));
}
Result
Price1 = 105143.0 MathFloor(Price1) = 105143.0 Price2 = 105143.0 MathFloor(Price2) = 105142.0 Price1>Price2 = true
Don't take double-number priming literally.

Thank you. I must have found the right solution after all, but I was worried about a mistake because of the incorrect alignment!

 

The remainder of one non-normalized number divided by another non-normalized number, the result is in any case non-normalized.

This function should be removed from the language altogether, so as not to traumatize the immature psyche.

 
Vladislav Andruschenko:

I may have found the right solution after all.

Unfortunately, your code is a demonstration of a complete misunderstanding of what you are doing. Try to get to the bottom of the issue.
 
Dmitry Fedoseev:

The remainder of one non-normalized number divided by another non-normalized number, the result is in any case non-normalized.

This function should be removed from the language altogether, so as not to traumatize the immature psyche.

Well, everything is normalized for me. That's what's so funny.
 
Vladislav Andruschenko:
Well, it's fine with me. That's the tricky part.
You're doing unnecessary conversions that cause you to lose signs.

Normalize only before you use the results of your calculations directly. Avoid all number conversions and conversions as much as possible beforehand.
 
Andrey Dik:
You are doing unnecessary conversions that cause loss of characters.
These are already desperate codes..... I've done it in different ways. But as said above. Probably because of the incorrectly taken I was sinning on the error. Although these variables were glitchy in the code as well.

Thank you all for your help and suggestions. But everything works clearly with float.
 
Vladislav Andruschenko:
with float everything works clearly.
One of the worst recommendations is to switch from double to float.
 
Vladislav Andruschenko:
Well, it's fine with me. That's the funny thing.
Where in the world is it normal?
 
Vladislav Andruschenko:
It's already desperate codes..... I've done it in different ways. But as said above. Probably because of incorrectly accepted I was sinning a mistake. Although these variables were glitchy in the code as well.

Thank you all for your help and suggestions. But everything works clearly with float.
Float is a number castration that gives you no advantage. It's better to deal with all the losses in conversions and use the highest possible precision - double.