473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

mod - rest of a division

Jo
Hi Guys!

I'm sorry for my stupid question.

I want to use the operator "mod" (perhaps mod is pascal and not c++)

to calculate the rest of a division, to separate the odd and even number of
an array.

do you know what is the name of operator I need ? ("mod" is pascal ?)

do I need some libraries ? math.h or wath ?

Thank you

Jo
Jul 23 '05 #1
7 17343
Jo wrote:
Hi Guys!

I'm sorry for my stupid question.

I want to use the operator "mod" (perhaps mod is pascal and not c++) to
calculate the rest of a division, to separate the odd and even number
of an array.

do you know what is the name of operator I need ? ("mod" is pascal ?)
%
do I need some libraries ? math.h or wath ?


No.

Jul 23 '05 #2
Jo wrote:
Hi Guys!

I'm sorry for my stupid question.

I want to use the operator "mod" (perhaps mod is pascal and not c++)

to calculate the rest of a division, to separate the odd and even number of
an array.

do you know what is the name of operator I need ? ("mod" is pascal ?)

do I need some libraries ? math.h or wath ?

Thank you

Jo


The operator is '%', there is no library required...

-Sacha
Jul 23 '05 #3

"Jo" <gr****@tiscali.it> schrieb im Newsbeitrag
news:8i**********************@news4.tin.it...
Hi Guys!

I'm sorry for my stupid question.

I want to use the operator "mod" (perhaps mod is pascal and not c++)

to calculate the rest of a division, to separate the odd and even
number of an array.

do you know what is the name of operator I need ? ("mod" is pascal
?)

do I need some libraries ? math.h or wath ?

if you want to do this on floats, you must use:
#include <math.h>

mod_val = fmod(number, divisor);

-Gernot
Jul 23 '05 #4
"Gernot Frisch" <Me@Privacy.net> wrote in message
news:35*************@individual.net...
"Jo" <gr****@tiscali.it> schrieb im Newsbeitrag
news:8i**********************@news4.tin.it...
I want to use the operator "mod" (perhaps mod is pascal and not c++) do I need some libraries ? math.h or wath ?

if you want to do this on floats, you must use:
#include <math.h>

mod_val = fmod(number, divisor);


Iirc, that should read

#include <cmath>

mod_val = std::fmod (number, divisor);

?

regards
--
jb

(reply address in rot13, unscramble first)
Jul 23 '05 #5
Jakob Bieling wrote:
"Gernot Frisch" <Me@Privacy.net> wrote in message
news:35*************@individual.net...
#include <math.h>

mod_val = fmod(number, divisor);

Iirc, that should read

#include <cmath>

mod_val = std::fmod (number, divisor);


Both are legal and both do the same thing.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #6
"Pete Becker" <pe********@acm.org> wrote in message
news:sp********************@rcn.net...
Jakob Bieling wrote:
"Gernot Frisch" <Me@Privacy.net> wrote in message
news:35*************@individual.net...
#include <math.h>

mod_val = fmod(number, divisor);
Iirc, that should read

#include <cmath>

mod_val = std::fmod (number, divisor);

Both are legal and both do the same thing.


Oh, did not know you can actually use math.h etc.

After a little more reading, I am now confused, though. I read 26.5/1-6
and D.5/2 of the Standard. In the former, they write about cmath/cstdlib
containing the same things as math.h/stdlib.h, _plus_ some additional
overloads. But in the latter, they write name.h includes the same thing as
cname, but places them in both the std and the global namespace.

Did I fail to see something? Afaik, it might make a difference, if
math.h includes those additions or not (ie. the long double overload, which
you need to avoid possible down-casting).

regards
--
jb

(reply address in rot13, unscramble first)
Jul 23 '05 #7
Jakob Bieling wrote:
After a little more reading, I am now confused, though. I read 26.5/1-6
and D.5/2 of the Standard. In the former, they write about cmath/cstdlib
containing the same things as math.h/stdlib.h, _plus_ some additional
overloads. But in the latter, they write name.h includes the same thing as
cname, but places them in both the std and the global namespace.

Did I fail to see something? Afaik, it might make a difference, if
math.h includes those additions or not (ie. the long double overload, which
you need to avoid possible down-casting).


When compiling C++ code math.h has the C++ overloads. As you noted,
cmath adds some things to the requirements for math.h from the C
standard. Appendix D says that when compiling C++ code math.h has all
the things that cmath has, and hoists them into the global namespace. So
math.h is usually not just the C header; it has to be modified for C++.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Tim Rowe | last post by:
If I do from __future__ import division then eval(1/2) gives me 0.5 as expected. But if I do print input("enter a sum: ") and enter 1/2 as the sum I get 0 as if I hadn't done the import. I thought...
2
by: Sebastian Haase | last post by:
Hi, I'm interested in having more people in our lab using numarray/NumPy instead of MatLab. For that I have put together a couple useful modules and written many myself. But then I got reminded of...
5
by: Jive | last post by:
I've got a program with Python 2.3 embedded. When I try to run a script containing "from __future__ import division", I get an exception: File "main2.py", line 3 from __future__ import divison...
15
by: joel | last post by:
I have a table which I want to update by dividing one field into another. The update runs with no errors, but the results come out as only a positive integer number. The datatype for the result...
9
by: Marcin | last post by:
How I can make division of two numbers placed in arrays, example: short int a = {2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2}; short int b =...
17
by: seb.haase | last post by:
Hi, Is it true that that "Python 3000" is dead ? Honestly I think that e.g. changing 5/2 to be 2.5 (instead of 2) would just break to much code :-( On the otherhand I'm using Python as "Matlab...
10
by: Mike S | last post by:
Does anyone know the logic behind why in VB.NET the result of a floating-point division ('/') is -rounded- on being converted to an integer type, such as with statements like Dim x As Integer =...
2
by: kermit | last post by:
For a long time,, There has been a discussion of trueFor division versus integer division in Python. I myslef prefer that / be used for integer division since almost always, I want the...
13
by: jamesonang | last post by:
Supposed unsigned int(32 bits) is the largest number that computer can represent with a single variable. Now, i have a big integer ( less than 64 bit, but great than 32 bit) . i represent it by...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.