你在C ++中的定点表示使用什么? [英] What do you use for fixed point representation in C++?

查看:184
本文介绍了你在C ++中的定点表示使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个用于财务数据的定点标准,你知道任何值得尝试吗?

I'm looking for a fixed-point standard to use for financial data, do you know any that is worth trying? Do you have any experience on the performance of that hand-made fixed-point classes?

推荐答案

我使用我的固定点数学类。它被设计为或多或少地代替浮子/双打。 http://codef00.com/coding

I use my fixed point math class. It is designed to be more or less a drop in replacement for floats/doubles. http://codef00.com/coding

EDIT :作为附注,我不会为此目的使用固定点类。我只是存储的分数(或十分之一分,或百分之一的百分之一需要)。只是直接做数学。然后,我会在向用户显示时适当地缩放该值。

EDIT: As a side note, I would not personally used a fixed point class for this purpose. I would instead just store the number of cents (or tenths of a cent, or hundredths of a cent as needed). A just do the math directly with that. Then I would scale the value appropriately when displaying to the users.

这篇关于你在C ++中的定点表示使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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