为什么使用“e0” 在c中定义的常量的末尾?

发布于 2024-07-17 07:53:18 字数 1136 浏览 12 评论 0原文

我正在尝试调试一个 perl 应用程序的问题,该应用程序调用一些 c 程序来进行文本编辑。

BATCH_JV_CSH_MAX 用于测试金额字段的最大值。 目前,如果金额超过 99,999,999.99,则会指示错误。 应该接受最大 999,999,999.99 的值。 嗯,无论如何,这就是文档中所述的内容。

它位于包含文件中:

#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

我还不知道该程序是如何工作的。 它可能会删除除数字之外的任何值并连接字符。 在继续之前,我想知道金额末尾的“e0”是什么意思。 在我决定询问这个小组之前,我在 Safari 中对一些 C 编程书籍进行了文本搜索。

该值在错误消息中打印出来,因此“999999999”比 1e9 更有意义

该值的使用方式如下:

/* 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() 获取已在另一个 C 程序中计算的值 tot_amt1。 它是“静态双”。

是的,我还有很多工作要做。 这是读入空格分隔记录并写出固定格式记录的过程的一部分。

谢谢。 凯茜

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

人│生佛魔见 2024-07-24 07:53:18

它表示 0 的指数。因此 5e05 x 10^0 == 5 x 1 == 5。 我认为宏的定义只是为了给数字提供浮点类型(作为仅使用 5.05f 的替代方案。)

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

陪你到最终 2024-07-24 07:53:18

99999999999e0 是浮点常数。 末尾的“e0”表示“*10^0”。 也就是

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

等等。

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.

以酷 2024-07-24 07:53:18

值 9999999999e0 是 C 表示科学记数法的方式。

9999999999 * 10^0

因此,如果您希望允许数字达到 1,000,000,000.00,您可以使用

#define BATCH_JV_CSH_MAX 1e9

Which 更容易阅读,IMO。 但如果您更喜欢完整版本,可以使用

#define BATCH_JV_CSH_MAX 1000000000e0

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
喜爱皱眉﹌ 2024-07-24 07:53:18

这是科学计数法。 它的意思是“乘以十的零次方”,即乘以 1。

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

与君绝 2024-07-24 07:53:18

999999999e0 是浮点表示。 0 是 10 的指数。9e0

== 9

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

9e0 == 9

浮云落日 2024-07-24 07:53:18

当然看起来像一个指数:

NUMex - NUM x 10 ^x

例如,12.345e2 = 1234.5

Sure looks like an exponent:

NUMex - NUM x 10 ^x

For example, 12.345e2 = 1234.5

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文