Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


non-int mod operator in c++?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Quasius   Members   -  Reputation: 122

Like
0Likes
Like

Posted 11 March 2005 - 04:27 PM

It seems that the mod operator in C++ will not work on anything but ints. For example: remainder = 130.7 % 50; gives an error, not remainder = 30.7 Is there a way to get the mod operator to take a double data type, or do I just need to do it manually and write my own "double mod" function?

Sponsor:

#2 smart_idiot   Members   -  Reputation: 1298

Like
0Likes
Like

Posted 11 March 2005 - 04:34 PM

fmod

#3 Mushu   Members   -  Reputation: 1396

Like
0Likes
Like

Posted 11 March 2005 - 04:40 PM

For those of us who are blinded by any non-black backgrounded page:
Quote:
#include <math.h>

// for doubles
fmod(double x, double y);

// for floats
fmodf(float x, float y);

[wink]

#4 Drew_Benton   Crossbones+   -  Reputation: 1727

Like
0Likes
Like

Posted 11 March 2005 - 04:48 PM

Quote:
Original post by smart_idiot
fmod


[lol] I was thinking of FMOD the sound library. I was like wow, what an 'idiot' [grin]. I should get some sleep now.

#5 supercrazy7474   Members   -  Reputation: 120

Like
0Likes
Like

Posted 11 March 2005 - 04:50 PM

Quote:
Original post by smart_idiot
fmod

lol, I thought that too.

#6 Zahlman   Moderators   -  Reputation: 1682

Like
0Likes
Like

Posted 11 March 2005 - 08:58 PM

Quote:
Original post by Mushu
For those of us who are blinded by any non-black backgrounded page:
Quote:
#include <math.h>

// for doubles
fmod(double x, double y);

// for floats
fmodf(float x, float y);

[wink]


Except that of course in C++ you want to include <cmath> instead, and (I think?) import the function names (or qualify them each time) from the std namespace. [smile]




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS