Question

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

Was it helpful?

Solution

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.)

OTHER TIPS

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.

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

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

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

9e0 == 9

Sure looks like an exponent:

NUMex - NUM x 10 ^x

For example, 12.345e2 = 1234.5

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top