首页 > 其他分享 >round

round

时间:2023-01-09 22:24:36浏览次数:34  
标签:envp int double float long excepts 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);

标签:envp,int,double,float,long,excepts,round
From: https://www.cnblogs.com/funwithwords/p/17038687.html

相关文章

  • Educational Codeforces Round 141 (Rated for Div. 2) Different Arrays
    Problem-D-Codeforces题意:给一个长度为n的数组a,下标从2到n-1,每个位置执行一次操作操作:设操作位置为i,$a_{i-1}+=a_i,a_{i+1}-=a_i$,或者$a_{i-1}-=a_i,a_......
  • Educational Codeforces Round 141 (Rated for Div. 2) A-E
    比赛链接A题意给一个数组\(a\),要求重排列以后\(a[i]\neqa[1,i-1]\),其中\(a[1,i-1]\)是前\(i-1\)项和。如果无解则输出NO;否则,给出一个合法的重排列后的\(a......
  • Codeforces Round #266 (Div. 2) C. Number of Ways (dp)
    https://codeforces.com/contest/466/problem/C题目大意:数组a由n个整数组成a[1],a[2],...,a[n]。计算将数组中的所有元素分成三个连续部分的方法,以使每个部分中的元素总和......
  • SMU Winter 2023 Round #2 (Div.2)(英文)
    A.MediumNumber题目:Giventhreedistinctintegersa,b,andc,findthemediumnumberbetweenallofthem.Themediumnumberisthenumberthatisneitherthe......
  • SMU Winter 2023 Round #1 (Div.2)
    A.不可以,总司令题目:扶苏当上了星战地球舰队的参谋长,但是她不太聪明。人工智能计算出,如果扶苏在一直回答“NO”的话,她在战役中判断完全正确的概率为x%;如果她一直在回答......
  • Educational Codeforces Round 141 (Rated for Div. 2) A-C题解
    比赛链接A、MakeitBeautiful一种构造方法:按照从大到小的顺序构造,可以发现前缀和永远大于当前值。但是需要特判存在两个最大值的情况。只需要将最小值与第二位交换位置......
  • Codeforces Round #646 (Div. 2) D交互
    A.OddSelection题意:给定n个数,是否能选k个数和为奇数分析:和为奇数只有一种情况:n个偶数+k个奇数(n任意,k为奇数)枚举奇数个数即可voidsolve(){a=b=......
  • Codeforces Round #842 (Div. 2)(B,D,E)
    CodeforcesRound#842(Div.2)(B,D,E)B题实在是没想到BB这个题大意是给你一个乱序的一到n的数,我们每次可以选择k个数,放到这个数组的最后面,问我们需要最少多少个操作可以......
  • Educational Codeforces Round 141
    A.MakeitBeautiful他想要变美,我们按照题目说的做就行,通过判断我们发现如果在sort一遍后sort(a+1,a+1+n);if(a[1]==a[n]){cout<<"NO"<<"\n";......
  • One Bamboo Contest Round #12(Clone from 2020 ICPC Shenyang)
    G.TheWitchwood签到#include<bits/stdc++.h>#defineintlonglongusingnamespacestd;intread(){intx=0,ch=getchar();while(ch<'0'||c......