完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
亲爱的大家,
我有一些带浮点值的奇怪舍入: 例如,当我在eeprom(校准参数)中写入0.05时,当我读到它时它变为0.049999997。 0.2变为0,199999988。 我使用Cosmic编译器,我试图在float.h中更改FLT_DIG但没有任何改变。 如果有人有线索请帮助我。 提前谢谢了 #floating-point --- just-say-no#stm8-stm8l-float-rounding-cosmic 以上来自于谷歌翻译 以下为原文 Dear all, I have some strange roundings with float values: for example when I write 0.05 in eeprom (calibration parameters) it becomes 0.049999997 when I read It. 0.2 becomes 0,199999988. I use Cosmic compiler, I tried to change FLT_DIG in float.h but nothing changes. If someone has a clue please help me. Many thanks in advance #floating-point---just-say-no #stm8-stm8l-float-rounding-cosmic |
|
相关推荐
4个回答
|
|
在浮点格式中,0.2和0.05都不能精确表示。谷歌IEE754并查看1985年和1985年的维基百科条目。 2008版标准。那些应该让你对你所看到的内容有所了解。
JDF 以上来自于谷歌翻译 以下为原文 Neither 0.2 nor 0.05 can be represented exactly in floating point format. Google IEE754 and check out the Wikipedia entries for both the 1985 & 2008 versions of the standard. Those should give you a good idea of what you're seeing. jdf |
|
|
|
|
|
|
|
如前所述,这是浮点的固有伪像。
避免浮点的另一个原因,除非你真的,有一个非常具体的需要... 以上来自于谷歌翻译 以下为原文 As already noted, this is an inherent artifact of floating-point. Another reason to avoid floating-point unless you really, have a very specific need for it... |
|
|
|
非常感谢所有人,我最终决定不使用浮点数。
以上来自于谷歌翻译 以下为原文 Many thanks to all, I finally decide not to use float numbers. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2922 浏览 1 评论
3293 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1877 浏览 1 评论
3729 浏览 6 评论
6142 浏览 21 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
30浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
31浏览 5评论
24浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
20浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
23浏览 5评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-3-18 16:18 , Processed in 0.685395 second(s), Total 81, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191