查一下编译器手册,是否支持double类型 我记得有些单片机的C编译器把double和float同等看待 如果是这样,程序里的99999999已经超过float可以表达的有效数据位数了
比如,KEIL C51实际上是不支持double类型的,但double类型声明的关键字可以出现的程序中,而不报错,下面是KEIL技术支持中的问与答:
QUESTION How do I enable 64-bit double-precision floating-point in C51?
ANSWER C51 provides IEEE 32-bit floating-point math but does not support 64-bit floating-point math. 64-bit math would be extremely slow on the 8051.
The double type is supported syntactically but is identical in implementation to the float type.
另外没看到最初的Energy[]赋值语句,执行到if语句时它的值到底是多少?
|