problems defining / returning a double 
Author Message
 problems defining / returning a double

Having a problem getting a valid return back on a double

in main I have

loop(6000000000)

in a header file I have

#define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

I have tried various combinations to achieve a valid double from loop.

What / where is the best way to get this done!

--



Thu, 01 Feb 2001 03:00:00 GMT  
 problems defining / returning a double

Quote:

> Having a problem getting a valid return back on a double

> in main I have

> loop(6000000000)

> in a header file I have

> #define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

> I have tried various combinations to achieve a valid double from loop.

> What / where is the best way to get this done!

<Jack>

Can you be more specific about what you are trying to do?  A for loop doesn't
return anything.  Is the variable gsla already defined somewhere, and
available from wherever you want to invoke this macro?  Or are you planning to
define it in the for loop each time, which you can do in C++ but not in C?

</Jack>
--



Thu, 01 Feb 2001 03:00:00 GMT  
 problems defining / returning a double

   Having a problem getting a valid return back on a double

   in main I have

   loop(6000000000)

That should be 6000000000., since without the . it's an integer that
overflows most system's integer limits.

   in a header file I have

   #define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

With gsla presumably defined as double?
--
(supporter of the campaign for grumpiness where grumpiness is due in c.l.c)

Please: do not email me copies of your posts to comp.lang.c
        do not ask me C questions via email; post them instead
--



Thu, 01 Feb 2001 03:00:00 GMT  
 problems defining / returning a double

Quote:

> Having a problem getting a valid return back on a double

> in main I have

> loop(6000000000)

> in a header file I have

> #define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

> I have tried various combinations to achieve a valid double from loop.

> What / where is the best way to get this done!

To get what done?  What are you expecting to get from loop?

Since I don't know what the problem is (sorry, I don't understand), all
I can suggest is that you change 6000000000 to 6000000000.0 or
6000000000UL or 6.0e9, since 6000000000 is an integer constant and might
overflow.

--

I believe we can change anything.
I believe in my dream.
    - Joe Satriani
--



Thu, 01 Feb 2001 03:00:00 GMT  
 problems defining / returning a double

|Having a problem getting a valid return back on a double
|
|in main I have
|
|loop(6000000000)
==========
The largest guaranteed value of an unsigned long int is
      4294967295UL
The largest guaranteed value of a long int is
      2147483647L
If you try to use values beyond these, tough.
===========
|
|in a header file I have
|
|#define loop(gslx) for (gsla=0; gsla<gslx; gsla++)
============
Don't do this sort of chickenshit redefinition of the
language.  It isn't all that hard to write for statements.


/* Newsgroup posts also e-mailed */
============

|
|I have tried various combinations to achieve a valid double from loop.
|
|What / where is the best way to get this done!
|
|
|--

--



Thu, 01 Feb 2001 03:00:00 GMT  
 problems defining / returning a double
I removed my previous attempts to properly define glsa as a double....The
value that I have forced into glsa on the sample code (6,000,000,000) was
primarily for testing purposes, but is not beyond reason as a possible value
that will be generated as a variable.  So.... The problem remains....
between the macro call in main (loop) and the header file the macro uses, I
need to get this value to accept a double.  Everything I have tried results
in an error relating to gsla being defined as a long.

But..it may be that I have a misunderstanding about just what exactly the
max value of a double is....?????  I thought it was well beyond
6,000,000,000????

Greg

Quote:


>> Having a problem getting a valid return back on a double

>> in main I have

>> loop(6000000000)

>> in a header file I have

>> #define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

>> I have tried various combinations to achieve a valid double from loop.

>> What / where is the best way to get this done!

><Jack>

>Can you be more specific about what you are trying to do?  A for loop
doesn't
>return anything.  Is the variable gsla already defined somewhere, and
>available from wherever you want to invoke this macro?  Or are you planning
to
>define it in the for loop each time, which you can do in C++ but not in C?

></Jack>
>--


--



Thu, 01 Feb 2001 03:00:00 GMT  
 problems defining / returning a double

Quote:

>loop(6000000000)

You probably need to say '6000000000.0', to tell the system you meant it to
be a double.

Quote:
>#define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

This looks like a very bad idea; most computers can't do anything significant
six billion times in any plausible time period.  If you're inventing a delay
loop, *DO NOT DO IT THIS WAY*.  Next year's computers will make your program
look silly.  Instead, find a clock and attach delays to it.

Quote:
>I have tried various combinations to achieve a valid double from loop.

>What / where is the best way to get this done!

Well, for one thing, where is 'gsla' defined?

Also, keep in mind that not everything in the range of a double is still in
the range a double can represent exactly; there comes a point on many systems
where 'x + 1.0' is still x, because the system doesn't have enough resolution
to keep track of numbers this large...

-s
--

C/Unix wizard, Pro-commerce radical, Spam fighter.  Boycott Spamazon!
Seeking interesting programming projects.  No recruiters need apply.
Visit my new ISP <URL:http://www.plethora.net/> --- More Net, Less Spam!
--



Thu, 01 Feb 2001 03:00:00 GMT  
 problems defining / returning a double

   But..it may be that I have a misunderstanding about just what exactly the
   max value of a double is....?????  I thought it was well beyond
   6,000,000,000????

Yes, but it's not a double if you don't put in a decimal point, see my
earlier post.
--
(apparently c.l.c's main grump now that firewind seems to have blown away)

Please: do not email me copies of your posts to comp.lang.c
        do not ask me C questions via email; post them instead
--



Thu, 01 Feb 2001 03:00:00 GMT  
 problems defining / returning a double
The missing decimal point was the problem!

Thanks!

Greg

Quote:


>> Having a problem getting a valid return back on a double

>> in main I have

>> loop(6000000000)

>> in a header file I have

>> #define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

>> I have tried various combinations to achieve a valid double from loop.

>> What / where is the best way to get this done!

>To get what done?  What are you expecting to get from loop?

>Since I don't know what the problem is (sorry, I don't understand), all
>I can suggest is that you change 6000000000 to 6000000000.0 or
>6000000000UL or 6.0e9, since 6000000000 is an integer constant and might
>overflow.

>--

>I believe we can change anything.
>I believe in my dream.
>    - Joe Satriani
>--


--



Fri, 02 Feb 2001 03:00:00 GMT  
 problems defining / returning a double
Thank you.  Once again, forgetting to do the proverbial
"DOTTING I's AND CROSSING T's" had bitten me!
The missing decimal point was indeed the problem.

Greg

Quote:


>   Having a problem getting a valid return back on a double

>   in main I have

>   loop(6000000000)

>That should be 6000000000., since without the . it's an integer that
>overflows most system's integer limits.

>   in a header file I have

>   #define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

>With gsla presumably defined as double?
>--
>(supporter of the campaign for grumpiness where grumpiness is due in c.l.c)

>Please: do not email me copies of your posts to comp.lang.c
>        do not ask me C questions via email; post them instead
>--


--



Fri, 02 Feb 2001 03:00:00 GMT  
 problems defining / returning a double
Thank you for your generous help!

Quote:

>The largest guaranteed value of an unsigned long int is
>      4294967295UL
>The largest guaranteed value of a long int is
>      2147483647L
>If you try to use values beyond these, tough.
>===========
>============
>Don't do this sort of chickenshit redefinition of the
>language.  It isn't all that hard to write for statements.


>/* Newsgroup posts also e-mailed */
>============

>|
>|I have tried various combinations to achieve a valid double from loop.
>|
>|What / where is the best way to get this done!
>|
>|
>|--

>--


--



Fri, 02 Feb 2001 03:00:00 GMT  
 problems defining / returning a double


Quote:
>Having a problem getting a valid return back on a double

>in main I have

>loop(6000000000)

>in a header file I have

>#define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

>I have tried various combinations to achieve a valid double from loop.

>What / where is the best way to get this done!

It is difficult to determine what you are attempting.
Perhaps:
#include <stdio.h>

/**********************************************
 ***         Put in header                 ***/    
unsigned long i;
#define loop(aslx) for(i = 0;i < aslx; ++i)
/***                                       ****
**********************************************/

int main(void) {
   loop(600000000);/* does nothing */
   loop(10) {
      printf("%lu\n",i);
      }
   return 0;
   }

Al Bowers                                
Tampa, FL

http://www.gate.net/~abowers/index.html
--



Fri, 02 Feb 2001 03:00:00 GMT  
 problems defining / returning a double

Quote:

> I removed my previous attempts to properly define glsa as a double....The
> value that I have forced into glsa on the sample code (6,000,000,000) was
> primarily for testing purposes, but is not beyond reason as a possible value
> that will be generated as a variable.  So.... The problem remains....
> between the macro call in main (loop) and the header file the macro uses, I
> need to get this value to accept a double.  Everything I have tried results
> in an error relating to gsla being defined as a long.

> But..it may be that I have a misunderstanding about just what exactly the
> max value of a double is....?????  I thought it was well beyond
> 6,000,000,000????

> Greg

<Jack>

Why not just write a function?

As for the maximum value of a double in your implementation, read the standard
file float.h.  The problem is that DBL_MAX - 1.0 might equal DBL_MAX.

</Jack>
--



Fri, 02 Feb 2001 03:00:00 GMT  
 problems defining / returning a double

Quote:





> > >#define loop(gslx) for (gsla=0; gsla<gslx; gsla++)

> > This looks like a very bad idea; most computers can't do anything significant
> > six billion times in any plausible time period.  If you're inventing a delay
> > loop, *DO NOT DO IT THIS WAY*.  Next year's computers will make your program
> > look silly.  Instead, find a clock and attach delays to it.

> Even this year's computers, as a compiler may very well optimise the loop out
> of exsitance.

Not to mention the fact that the OS can very likely find better things
for the CPU to do than count to six billion.

--

Chris Volpe                    
GE Corporate R&D            
PO Box 8                        Email: "volpecr" AT "crd.ge.com"
Schenectady, NY 12301           Web:   http://www.crd.ge.com/~volpecr
Note: News postings do not constitute a GE Corporate communication
--



Sat, 03 Feb 2001 03:00:00 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. problems defining / returning a double

2. problem returning a very large double

3. Problem returning doubles from a function

4. Problem with Double.IsNan() and Double.Nan

5. Defining an array of doubles

6. double defined operator delete

7. result of double*double is no double

8. Allowing function to return double and/or NULL

9. best failure signal when returning double

10. OCX Control Returning *double?

11. why return double from difftime() ?

12. Please Help: trouble returning doubles

 

 
Powered by phpBB® Forum Software