C语言 - 如何从双重得到绝对值 [英] How to get absolute value from double - c-language

查看:99
本文介绍了C语言 - 如何从双重得到绝对值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从反面双重绝对值 - 我以为 ABS - 功能很容易,因为在Java中使用 - 但不是

I want the absolute-value from a negative double - and I thought the abs-function was as easy to use as in java - but NOT!

看来, ABS - 函数,因为我有值为3.8951返回一个int和输出为3.000000

It seems that the abs-function returns an int because I have the value 3.8951 and the output is 3.000000

double d1 = abs(-3.8951);
printf("d1: ...%lf", d1);

我怎样才能解决这个问题呢?那就是 - 我想要的绝对值双击

推荐答案

使用 晶圆厂() (在<大骨节病>文件math.h < /骨节病>)来获得绝对值为双/浮法

double d1 = fabs(-3.8951);

这篇关于C语言 - 如何从双重得到绝对值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆