473,883 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 17378
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******** *****@individua l.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******** *****@individua l.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******** ************@rc n.net...
Jakob Bieling wrote:
"Gernot Frisch" <Me@Privacy.net > wrote in message
news:35******** *****@individua l.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
2142
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 input was supposed to give the same behaviour as an eval on raw input -- why the difference here?
2
1925
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 a new / upcoming feature of Python: "2/3 == 1.5" AKA PEP 238. I'm very interested in putting lots of "from __future__ import division" lines into my code especially since numarray (the new NumPy) now supports it.
5
2263
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 SyntaxError: future feature divison is not defined Anyone know how to fix that? BTW, when I run the program with CO_FUTURE_DIVISION set in PyCompilerFlags, division works the new way, as it should.
15
51073
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 field is float. The datatype for the other fields are int. I have tried testing by dividing 7 by 10000, which should give me 0.0007. The result in the database is 0.
9
12749
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 = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}; short int result = a / b; 'division without additional lib's and header files, only in standart C.
17
2439
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 replacement" and would generally like 5/2 ==2.5 So, I was contemplating to default all my modules/scripts to start with "from __future__ import division" but if it is never coming (in this decade, that is) then it would be a
10
3208
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/3 'after assignment, x is 1, whereas a sane person would say it should be 0 Does Microsoft have a reason for this design decision? I understand that this type of rounding can reduce the overall error in long computation chains by reducing the...
2
3880
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 result of the division be truncated to integer. However, today I reviewed the method to be used in Python to get true division, and this gave
13
7133
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 this way: unsigned int dividend : divident store low 32 bits of big integer, dividend store high 32 bits of big integer.
0
9953
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10868
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9591
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7984
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7137
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3242
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.