473,386 Members | 1,785 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,386 software developers and data experts.

modf() question

Given that modf is prototyped as

double modf( double x, double *iptr );

is the behavior of the function well-defined if the address of x is
passed as the value of iptr?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #1
3 1612
In message <d3**********@chessie.cirr.com>
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Given that modf is prototyped as

double modf( double x, double *iptr );

is the behavior of the function well-defined if the address of x is
passed as the value of iptr?


Absolutely. x is passed by value, so all that can happen is that the caller
passes a pointer to the argument it's passing. That won't point at the
copy of the parameter that the modf function sees, so there's no possible
aliasing problem.

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1728 727430
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #2
Christopher Benson-Manica wrote:
Given that modf is prototyped as

double modf( double x, double *iptr );

is the behavior of the function well-defined if the address of x is
passed as the value of iptr?


Technically, the question is fundamentally flawed because here, x is
a function argument and its address cannot be passed as another argument
of the same call. So this question is plain rubbish.

Now if that was meant to say "if the address of the variable passed
in the function call as the first argument", that's another story.
But anything could be passed as the first argument of this function,
including literals and expressions, so the parameter doesn't necessarily
even have an address (as defined by the operator '&').

Thus, this question doesn't make any sense per se. Ask your teacher to
write a better question, then work on it.
Nov 14 '05 #3
Kevin Bracey <ke**********@tematic.com> spoke thus:
Absolutely. x is passed by value, so all that can happen is that the caller
passes a pointer to the argument it's passing. That won't point at the
copy of the parameter that the modf function sees, so there's no possible
aliasing problem.


I should have been able to replicate that thought process - time for
more coffee, I suppose. Thanks.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #4

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

Similar topics

3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
3
by: MarkN | last post by:
modf() is a C Standard Library function double modf(double x, double* ip); returns fractional part and assigns to *ip integral part of x, both with same sign as x I have encountere a situation...
1
by: mcruz | last post by:
hi, I was using the following function in a C++ program. I am now "porting" it to C# and I can not find an equivalent to: modf function. As described below. double modf ( double x , double *...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
1
by: Patrick Sullivan | last post by:
Is there any VB function that can do what modf() does in Visual C/C++, like Modf: Splits a floating-point value into fractional and integer parts. The integer portion is stored in *intptr...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
12
by: bsabiston | last post by:
Hi, I'm trying to get the fractional part of a floating point number. I've tried fmod() and modf(), and while both do work, they also occasionally return 1.0 for the fractional part of the number...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.