round

复制代码
#include <math.h>
#include <iostream>
using namespace std;

#define fn rint

// https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
#define xstr(s) str(s)
#define str(s) #s

int main() {
  const char* name = xstr(fn);
  double a[] = { -0.6, -0.5, -0.4, 0.4, 0.5, 0.6 };
  for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
    double x = a[i];
    cout << name << '(' << x << ") = " << fn(x) << endl;
  }
}

#include <math.h>

double nearbyint(double x);
float nearbyintf(float x);
long double nearbyintl(long double x);

double rint(double x);
float rintf(float x);
long double rintl(long double x);

double round(double x);
float roundf(float x);
long double roundl(long double x);

double trunc(double x);
float truncf(float x);
long double truncl(long double x);

long lrint(double x);
long lrintf(float x);
long lrintl(long double x);

long long llrint(double x);
long long llrintf(float x);
long long llrintl(long double x);

#include <fenv.h>

int feclearexcept(int excepts);
int fegetexceptflag(fexcept_t *flagp, int excepts);
int feraiseexcept(int excepts);
int fesetexceptflag(const fexcept_t *flagp, int excepts);
int fetestexcept(int excepts);

int fegetround(void);
int fesetround(int rounding_mode);

int fegetenv(fenv_t *envp);
int feholdexcept(fenv_t *envp);
int fesetenv(const fenv_t *envp);
int feupdateenv(const fenv_t *envp);

https://www.codenong.com/32746523/

halfway cases可能是-1.5, -0.5, 0.5, 1.5, 2.5们?halfway可以作副词,case可以做动词, The reactor will be halfway cased in metal. 语法没错吧?:-)
复制代码
posted @   Fun_with_Words  阅读(35)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
历史上的今天:
2022-01-09 A Child's History of England.111
2022-01-09 A Child's History of England.110
2022-01-09 除法到底慢不慢?
2022-01-09 anchor
2022-01-09 amount, ample.六级
2022-01-09 amount, ample
2022-01-09 A Child's History of England.109









 和4张牌。

点击右上角即可分享
微信分享提示