By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,955 Members | 1,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,955 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
...

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
Jul 22 '05 #2

P: n/a
Simon wrote:
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.

Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.