C#中如何取绝对值函数的方法详解

来源:这里教程网 时间:2026-02-21 13:40:47 作者:

本文主要介绍了c# 中取绝对值的函数。具有很好的参考价值。下面跟着小编一起来看下吧

话不多说,请看代码:

System.Math.Abs(float value);
System.Math.Abs(decimal value);
System.Math.Abs(int value);
System.Math.Abs(double value);
System.Math.Abs(sbyte value);
System.Math.Abs(long value);
System.Math.Abs(short value);

PS:下面看下c++ 取绝对值函数

int abs(int   i) 返回整型参数i的绝对值    

  double cabs(struct   complex   znum) 返回复数znum的绝对值     

  double fabs(double   x) 返回双精度参数x的绝对值   

  long labs(long   n) 返回长整型参数n的绝对值  

 abs,   labs,   llabs,   imaxabs   -   compute   the   absolute   value   of   an   integer.    

SYNOPSIS   

      #include  <stdlib.h>  
        int  abs(int  j);  
        long  int  labs(long  int  j);  
        long  long  int  llabs(long  long  int  j);  
        #include  <inttypes.h>  
        intmax_t  imaxabs(intmax_t  j);

相关推荐