为什么使用“e0” 在c中定义的常量的末尾?
我正在尝试调试一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
它表示 0 的指数。因此
5e0
是5 x 10^0 == 5 x 1 == 5
。 我认为宏的定义只是为了给数字提供浮点类型(作为仅使用5.0
或5f
的替代方案。)It means an exponent of 0. So
5e0
is5 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 just5.0
or5f
.)这是科学记数法
it is the scientific notation
99999999999e0 是浮点常数。 末尾的“e0”表示“*10^0”。 也就是
等等。
99999999999e0 is a floating point constant. the "e0" at the end means "*10^0". That is
etc.
值 9999999999e0 是 C 表示科学记数法的方式。
因此,如果您希望允许数字达到 1,000,000,000.00,您可以使用
Which 更容易阅读,IMO。 但如果您更喜欢完整版本,可以使用
The value 9999999999e0 is C's way of representing the scientific notation of
So if you want to allow numbers up to 1,000,000,000.00, you could use
Which is much easier to read, IMO. But if you'd prefer the full version, you can use
这是科学计数法。 它的意思是“乘以十的零次方”,即乘以 1。
It's scientific notation. It means "times ten to the zeroth power", or times 1.
http://en.wikipedia.org/wiki/Scientific_notation#E_notation
http://en.wikipedia.org/wiki/Scientific_notation#E_notation
999999999e0 是浮点表示。 0 是 10 的指数。9e0
== 9
999999999e0 is a floating point representation. 0 is the exponent of 10.
9e0 == 9
当然看起来像一个指数:
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