yet more problems with my double/fabs(...)

S

Simon

Hi,

I have a function that always crashes and I am not too sure why.

Here is the code, (and the value that cause the crash).

#include <math.h>
....

bool ConvertToString( double num, char *szBuffer, int nSize )
{
// number must be +ve
num = fabs(num); // <- Crashes here, (in the fabs
function)

... // more string stuff.
}

The exact number that causes the crash is "10.463055555555556"

any reason why this should happen?

- I am not just converting the number to a string so I need my own function.
- I have no problems with my XP machine, it only happens on my Win98
machine.
- I compiled it on the WinXP machine using VC6.
- The crash error given is "EXCEPTION_FLT_INVALID_OPERATION"

Many thanks in advance again.

Simon
 
S

Simon

...

bool ConvertToString( double num, char *szBuffer, int nSize )
{
// number must be +ve
num = fabs(num); // <- Crashes here, (in the fabs
function)

... // more string stuff.
}

The exact number that causes the crash is "10.463055555555556"

For the record, the value "num" is
int inum = 0;
-648000 < inum > +648000

double num = ((double)inum / 3600.0 );

regards.

Simon
 
P

Pierre Couderc

Simon said:
Hi,

I have a function that always crashes and I am not too sure why.

Here is the code, (and the value that cause the crash).

#include <math.h>
...

bool ConvertToString( double num, char *szBuffer, int nSize )
{
// number must be +ve
num = fabs(num); // <- Crashes here, (in the fabs
function)

... // more string stuff.
}

The exact number that causes the crash is "10.463055555555556"

any reason why this should happen?

- I am not just converting the number to a string so I need my own function.
- I have no problems with my XP machine, it only happens on my Win98
machine.
- I compiled it on the WinXP machine using VC6.
- The crash error given is "EXCEPTION_FLT_INVALID_OPERATION"

Many thanks in advance again.

Simon
Have you tried this exact sequence outside your application, in a small
ad hoc application just to test this sequence?
To check if the problem may come from the rest of your application.

Pierre Couderc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top