LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-30-2010, 06:39 AM   #1
amwjatyvh
LQ Newbie
 
Registered: Sep 2009
Location: Tianhe,Guangzhou,Guangdong,China
Distribution: Red Hat,Ubuntu,Fedora
Posts: 14

Rep: Reputation: 0
A question about the fmod() function in C...


Can you offer me the code about fmod() in C...
I want to know how this function work, i am very interested in it because i have no idea to implement it, thanks your consideration!

==========================================
i want to know... how to write the function... not 'how to use the function'...
can anyone post the source codes of this function here?

Last edited by amwjatyvh; 05-30-2010 at 08:08 AM.
 
Old 05-30-2010, 06:44 AM   #2
brazilnut
Member
 
Registered: Nov 2007
Posts: 113

Rep: Reputation: 16
Here's an example:

http://www.codecogs.com/reference/c/math.h/fmod.php


also try:
Code:
$ man fmod
for more info...
 
Old 05-30-2010, 06:49 AM   #3
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by amwjatyvh View Post
Can you offer me the code about fmod() in C...
I want to know how this function work, i am very interested in it because i have no idea to implement it, thanks your consideration!
I think the simplest way is to check how the open-source math library (libm) implements this function. Check out the sources of the GNU C library (libm is a part of glibc) and look at

Code:
glibc-x.y/math/w_fmod.c
Andi
 
Old 05-30-2010, 07:37 AM   #4
amwjatyvh
LQ Newbie
 
Registered: Sep 2009
Location: Tianhe,Guangzhou,Guangdong,China
Distribution: Red Hat,Ubuntu,Fedora
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by brazilnut View Post
Here's an example:

http://www.codecogs.com/reference/c/math.h/fmod.php


also try:
Code:
$ man fmod
for more info...
Oh, may be i haven't explain my question clearly...i am so sorry...

i want to know... how to write the function... not 'how to use the function'... thanks!
 
Old 05-30-2010, 09:01 AM   #5
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by amwjatyvh View Post
i want to know... how to write the function... not 'how to use the function'... thanks!
Right! So, why don't you then lookup a reference implementation!? I already posted a link to a reference implementation ... BTW, are you already familiar with the layout of the IEEE floating point specification? I think this is somehow crucial :-) to write such a function ...

Andi
 
Old 05-30-2010, 09:53 AM   #6
amwjatyvh
LQ Newbie
 
Registered: Sep 2009
Location: Tianhe,Guangzhou,Guangdong,China
Distribution: Red Hat,Ubuntu,Fedora
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ForzaItalia2006 View Post
Right! So, why don't you then lookup a reference implementation!? I already posted a link to a reference implementation ... BTW, are you already familiar with the layout of the IEEE floating point specification? I think this is somehow crucial :-) to write such a function ...

Andi
Oh,my god!Thanks for remind me that link...i feel ashamed...
At first i just glance the site you linked...so i overlook the sentence----"The return value is x - n y, where n is the quotient of x / y, rounded to the first integer towards zero."...i so damn foolish!!!I will be care next time...
To the layout of the IEEE floating point specification...it is my first time to here now and i go to read it right now...
Thanks very much!Please forgive my negligence!
 
Old 05-30-2010, 01:27 PM   #7
brazilnut
Member
 
Registered: Nov 2007
Posts: 113

Rep: Reputation: 16
mmm, syntax is a funny thing...

Last edited by brazilnut; 05-30-2010 at 01:28 PM. Reason: just to see
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacement for FMOD? thedevilsjester Programming 12 06-04-2007 02:37 PM
Question about the -> or < function, as seen in this example... RHLinuxGUY Programming 12 04-10-2006 09:04 AM
Racer + FMOD = X crash :/ k0ljat Linux - Games 2 06-16-2004 10:16 AM
A question about the gets() function in C OrganicX Programming 3 10-20-2003 01:11 PM
fmod installation jadukor_bd Linux - Software 0 09-01-2003 09:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration