Return type of floor()

Posted By: JMMAC

Return type of floor() - 05/25/23 13:45

Hi,
I'm at the start of my learning curve with Zorro and I have a couple of questions.


1) The Zorro manual says floor() returns a var/double but then gives an example where it returns an int.

int a = floor(b);

This obviously doesn't work and "a" will be 0 or have the wrong value. I guess it's an error in the manual.

But this leads to another question, why do floor(), ceil() and round() return doubles and not ints?

In my Zorro code I'm using "Lots" to enter my position size which I believe is an int. So should I use something like:

Lots = (int)round(...); ?


2) When I print to the log file, to have the output well formatted, it seems I have to put a \n at the beginning of the string and not at the end as one would expect when printing to a terminal:

print(TO_LOG,"\nLotAmmount = %f", LotAmount);

Is there a reason for that?

Thank you,
Jaime.
Posted By: AndrewAMD

Re: Return type of floor() - 05/25/23 14:17

1) Double casts to int, so it's not wrong, so long as you don't need floating point values.
© 2024 lite-C Forums