views:

312

answers:

8

Hi Everyone,

I'm trying to debug a problem with a perl application that calls some c programs to do text editing.

BATCH_JV_CSH_MAX is used to test the maximum value of an amount field. It currently indicates an error if the amount is over 99,999,999.99. Is is supposed to accept values up to 999,999,999.99. Well, that is what is stated in the documentation, anyway.

Here it is in the include file:

#define PROJ_SZ 6
#define REF_SZ  9
#define DESC_SZ 22
#define TRAN_AMT_MAX  9999999999e0
#define BATCH_AMT_MAX 9999999999e0
#define BATCH_JV_CSH_MAX 99999999999e0
#define BATCH_CNT_MAX 99999

I don't know yet how the program works. It probably strips out any value other than a number and concats the characters. I want to know what the 'e0' at the end of the amount means before I continue. I did a text search in a few c programming books in Safari before I decided to ask this group.

This value is printed out in an error message so '999999999' is more meaningful than 1e9

The value is used like this:

/* Batch total amount 1 - debit dollars */
/* Check for overflow */

if (fabs(get_tot_amt1()) > BATCH_JV_CSH_MAX)
{
    fprintf(stderr, "\n*** Error: Transaction debit amount overflow\n");

    fprintf(stderr, "\n***        Maximum expected: %.0f\n",
        BATCH_JV_CSH_MAX);

    return (FALSE);
}

sprintf(in_batch_sum.batch_debit_amt, "%011.0f", get_tot_amt1());

get_tot_amt1() gets a value tot_amt1 which has been calculated in another c program. It is "static double".

Yup, I have lots of work to do. This is part of a process that reads in a space delimited record and writes out a fixed format record.

Thanks. Cathy

+10  A: 

It means an exponent of 0. So 5e0 is 5 x 10^0 == 5 x 1 == 5. I think the macros are defined like that just to give the numbers a float type (as an alternative to using just 5.0 or 5f.)

Ates Goral
Minor clarification - without an 'f' or 'L' at the end (case doesn't matter), the type of the constant is double.
Michael Burr
Another minor clarification, you don't actually need the 0, so 5.0, 5. and 5e0 are all floating-point, double constants.
Jason Coco
"as an alternative to using just 5.0 or 5f" -- half wrong. If 5f were used then the type would be float instead of double. The original poster needs accuracy to more than 10 decimal digits so she needs double precision.
Windows programmer
+2  A: 

it is the scientific notation

dfa
A: 

It's scientific notation. It means "times ten to the zeroth power", or times 1.

leander
+2  A: 

99999999999e0 is a floating point constant. the "e0" at the end means "*10^0". That is

1e2 = 100.0
1e-1 = .1
1e0 = 1.0

etc.

jpalecek
A: 

999999999e0 is a floating point representation. 0 is the exponent of 10.

9e0 == 9

Cătălin Pitiș
+1  A: 

The value 9999999999e0 is C's way of representing the scientific notation of

9999999999 * 10^0

So if you want to allow numbers up to 1,000,000,000.00, you could use

#define BATCH_JV_CSH_MAX 1e9

Which is much easier to read, IMO. But if you'd prefer the full version, you can use

#define BATCH_JV_CSH_MAX 1000000000e0
Rick Copeland
A: 

Sure looks like an exponent:

NUMex - NUM x 10 ^x

For example, 12.345e2 = 1234.5

cookre