Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

non-int mod operator in c++?

4: Adsense

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   

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?

#2 smart_idiot   Members   

1298
Like
0Likes
Like

Posted 11 March 2005 - 04:34 PM

fmod

#3 Mushu   Members   

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   Members   

1851
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   

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   Members   

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.