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 @ 2023-01-09 22:14  Fun_with_Words  阅读(32)  评论(0编辑  收藏  举报









 张牌。