广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 15277 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
rickysteed
个人头像
个人文章 个人相簿 个人日记 个人地图
初露锋芒
级别: 初露锋芒 该用户目前不上站
推文 x0 鲜花 x9
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
文章表情[C/C++][精华] fabs() 这个函式的作用?
这是我再 这边看的的一个程式
#define Epsilon 1.0E-6 /*控制解的精度*/
#include<math.h>
main()
{
float a,x0,x1;
printf("请输入要求的数:");
scanf("%f ..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容



献花 x0 回到顶端 [楼 主] From:台湾中华电信 | Posted:2005-06-17 00:06 |
MarkTzen 手机
数位造型
个人文章 个人相簿 个人日记 个人地图
特殊贡献奖
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x14
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

查查msdn:
函式名称:fabs
说明:
Calculates the absolute value of the floating-point argument.

Function prototype:
double fabs( double x );

回传值:
fabs returns the absolute value of its argument. There is no error return.

Example:

/* ABS.C: This program computes and displays
* the absolute values of several numbers.
*/

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

void main( void )
{
  int   ix = -4, iy;
  long   lx = -41567L, ly;
  double dx = -3.141593, dy;

  iy = abs( ix );
  printf( "The absolute value of %d is %d\n", ix, iy);

  ly = labs( lx );
  printf( "The absolute value of %ld is %ld\n", lx, ly);

  dy = fabs( dx );
  printf( "The absolute value of %f is %f\n", dx, dy );
}

输出结果:

The absolute value of -4 is 4
The absolute value of -41567 is 41567
The absolute value of -3.141593 is 3.141593

此文章被评分,最近评分记录
财富:50 (by codeboy) | 理由: 感谢您的解惑...收益良多~^^


献花 x0 回到顶端 [1 楼] From:台湾中华电信 | Posted:2005-06-17 01:26 |
allenmail 手机
数位造型
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x20
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

是"绝对值"的意思
例如:fabs(-3.6) = 3.6

此文章被评分,最近评分记录
财富:10 (by codeboy) | 理由: 感谢您的回答~


献花 x0 回到顶端 [2 楼] From:台湾教育部 | Posted:2005-06-22 17:19 |
RunTime
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

绝队值不是abs而已吗= =??


献花 x0 回到顶端 [3 楼] From:局域网对方和您在同一内部网 | Posted:2005-06-26 18:59 |
flexu
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

iy = abs( ix );
printf( "The absolute value of %d is %d\n", ix, iy);

ly = labs( lx );
printf( "The absolute value of %ld is %ld\n", lx, ly);

dy = fabs( dx );
printf( "The absolute value of %f is %f\n", dx, dy );

abs是int数字的绝对值
labs是long数字的绝对值
fabs是float数字的绝对值

此文章被评分,最近评分记录
财富:50 (by codeboy) | 理由: 感谢您的解惑...收益良多~^^


献花 x0 回到顶端 [4 楼] From:台湾 | Posted:2005-07-03 10:04 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.018131 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言