C浮点 [英] C floating point

查看:71
本文介绍了C浮点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C支持单精度浮点和双精度

浮点但它是否支持固定浮点?我已经阅读了

,固定浮点数比单精度更准确

处理美元和美分时的浮点数。

解决方案

j0******@engineer.com (j0mbolar)写道:

C支持单精度浮点和双精度浮点但它是否支持固定浮点?




不,但是使用整数来模拟很容易。


Richard


2004年3月1日06: 46:51 -0800, j0******@engineer.com (j0mbolar)写道:

C支持单精度浮点和双精度浮点但它是否支持固定浮点?


不幸的是,

a)固定浮点是一个矛盾的术语。我相信你的意思是

固定点 (与浮点或整数相反)

b)否,标准C不支持固定浮点。 (原文如此)数字,既不是语言水平也不是图书馆一级的b $ b。

我已经读过
固定浮点比单个更精确处理美元和美分时的精确度浮点数。




-

Lew Pitcher

IT顾问,企业应用架构,

企业技术解决方案,道明银行金融集团


(表达的意见是我自己的,而不是我的雇主'') />


j0******@engineer.com (j0mbolar )写道:

C支持单精度浮点和双精度浮点但它是否支持固定浮点?


这个点如何固定和浮动?我猜你的意思是

定点分数,比如123.45,其中

总是在点之后的2位小数。

我已经读过固定浮点在处理美元和美分时比单个精确浮点更精确。




只代表一切作为美分内部并在输入时转换它或

输出,例如


int amount = 12345; / *


C supports single precision floating point and double precision
floating point but does it support fixed floating point? i''ve read
that fixed floating point is more accurate than single precision
floating point when dealing with dollars and cents.

解决方案

j0******@engineer.com (j0mbolar) wrote:

C supports single precision floating point and double precision
floating point but does it support fixed floating point?



No, but it''s pretty easy to simulate using integers.

Richard


On 1 Mar 2004 06:46:51 -0800, j0******@engineer.com (j0mbolar) wrote:

C supports single precision floating point and double precision
floating point but does it support fixed floating point?
Unfortunately,
a) "fixed" floatingpoint is a contradiction in terms. I believe you mean
"fixed point" (as opposed to "floating point" or "integer")
b) No, Standard C does not support "fixed floating point" (sic) numbers, neither
at the language level nor at the library level.
i''ve read
that fixed floating point is more accurate than single precision
floating point when dealing with dollars and cents.



--
Lew Pitcher
IT Consultant, Enterprise Application Architecture,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers'')


j0******@engineer.com (j0mbolar) writes:

C supports single precision floating point and double precision
floating point but does it support fixed floating point?
How can the point be both fixed and floating? I''m guessing that you mean
fixed point fractional numbers, i.e. something like 123.45, where there
are always 2 decimal digits after the point.
i''ve read that fixed floating point is more accurate than single
precision floating point when dealing with dollars and cents.



Just represent everything as cents internally and convert it on input or
output, e.g.

int amount = 12345; /*


这篇关于C浮点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆