有一个C#等效的c ++ fesetround()函数? [英] Is there an C# equivalent of c++ fesetround() function?

查看:164
本文介绍了有一个C#等效的c ++ fesetround()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个C#库进行区间算术,为此目的,我需要
设置浮点操作舍入模式为向上和向下。我知道在C ++
它可以实现与fesetround()函数。在C#中有一个等价的
或者如果没有,我该如何实现呢?

I'm writting a C# library for interval arithmetic, and for that purpose I need to set floating-point operations rounding mode to Up and Down. I know that in C++ it can be achieved with a fesetround() function. Is there an equivalent in C#, or if there isn't, how can I achieve this the other way?

推荐答案

p>我遵循Pascal Cuoq的建议,并创建了一个非常简单的一个功能组件。

I followed Pascal Cuoq's advice and created a very simple - one function assembly. I post it in here if anyone else would ever experience such a problem.

我使用我的lib解决方案:

Solution using my lib:


  1. 从以下位置下载dll档案: https:// www .dropbox.com / s / o3vfxe4rpefhly7 / RoundModeUtil.dll

  2. 在项目中添加对库的引用。

  3. 使用RoundModeUtils ;
  4. 用法:

static void RoundModeConfig::setround( int mode );

// mode can be set to one of the following values: 
static int RoundModeConfig::UPWARD
static int RoundModeConfig::DOWNWARD
static int RoundModeConfig::DEFAULT     // To nearest mode.
static int RoundModeConfig::TOWARDZERO


感谢Hans Passant为您的建议,我应该记住。
感谢大家的帮助,希望有人会发现我的DLL有用:)

Thanks Hans Passant for your advice,i should keep it in mind. Thanks everybody for help, hope someone will find my dll useful :)

这篇关于有一个C#等效的c ++ fesetround()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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