Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Grant, AndrewAMD), 911 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
modulus and floats... why not? #300679
12/04/09 11:24
12/04/09 11:24
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hi all. Evil strikes out again!

Can anyone tell me, and maybe point to where it is in the manual,
that it is 'against the rules' to use the modulus operator %
with float or double variables in lite-c?

I get compile errors.
float time = 0;
{code} if(integer(time%1000)>(24*12))
{error} "Syntax error. Cant convert MOD:FLOAT:FLOAT:FLOAT"

Any suggestions? Is my code possibly bad or is there a trick I havent found?

Thanks in advance.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: modulus and floats... why not? [Re: EvilSOB] #300683
12/04/09 12:34
12/04/09 12:34
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Yeh there is a restriction in C to using the modulus operator only on integers. It can't be used for floats/doubles.

You can create you're own modulus function for floats using this simple equation...

remainder = numerator - quotient * denominator

I believe there is a function like this called 'fmod' in C++.



Last edited by DJBMASTER; 12/04/09 12:37.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1