价值的标志 [英] sign of a value

查看:83
本文介绍了价值的标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起这个愚蠢的小问题,但是有什么功能可以获得价值的标志吗?

sorry for this silly little question, but whats the function to grab
the sign of a value?

推荐答案

tarmat在新闻中写道:jr ******************************** @ 4ax.com:
tarmat wrote in news:jr********************************@4ax.com:
抱歉这个愚蠢的小问题,但有什么功能可以抓住值的标志吗?
sorry for this silly little question, but whats the function to grab
the sign of a value?




bool is_negative = value< ; 0;


希望回答是愚蠢的足够:)。


Rob。

-
http://www.victim-prime.dsl.pipex.com/


2003年12月3日格林尼治标准时间11:56:40,Rob Williscroft

< rt*@freenet.REMOVE.co.uk>写道:
On 03 Dec 2003 11:56:40 GMT, Rob Williscroft
<rt*@freenet.REMOVE.co.uk> wrote:
tarmat在新闻中写道:jr ****************************** **@4ax.com:
tarmat wrote in news:jr********************************@4ax.com:
对不起这个愚蠢的小问题,但是有什么功能可以抓住值的标志吗?
sorry for this silly little question, but whats the function to grab
the sign of a value?



bool is_negative = value< 0;

希望答案是愚蠢的足够的:)。

Rob。



bool is_negative = value < 0;

Hope the answere is "silly" enough :).

Rob.



nope那个傻逼的Rob。它也没有回答我的

问题。我想知道返回

值的函数的名称。


nope that''s nowhere near silly enought Rob. It doesn''t answer my
question either. I want to know the name of the function that returns
the sign of a value.


tarmat在新闻中写道:r2 **** ****************************@4ax.com:
tarmat wrote in news:r2********************************@4ax.com:
2003年12月3日11 :格林威治标准时间56:40,Rob Williscroft
< rt*@freenet.REMOVE.co.uk>写道:
On 03 Dec 2003 11:56:40 GMT, Rob Williscroft
<rt*@freenet.REMOVE.co.uk> wrote:
tarmat在新闻中写道:jr ****************************** **@4ax.com:
tarmat wrote in news:jr********************************@4ax.com:
对不起这个愚蠢的小问题,但是有什么功能可以抓住值的标志吗?
sorry for this silly little question, but whats the function to grab
the sign of a value?



bool is_negative = value< 0;

希望答案是愚蠢的足够的:)。

Rob。



bool is_negative = value < 0;

Hope the answere is "silly" enough :).

Rob.



nope那个傻逼的Rob。它也没有回答我的问题。我想知道返回
值的符号的函数的名称。


nope that''s nowhere near silly enought Rob. It doesn''t answer my
question either. I want to know the name of the function that returns
the sign of a value.




Ok


模板< typename T>

bool sign_of_value(T const& value)

{

返回值< 0;

}


运气好(所有警告都打开并且是一个完整的编译器),


unsigned u = 0;

bool b = sign_of_value(u);


应该产生编译时警告。


BTW,为什么你认为有一个the函数返回一个值的符号

,假设它被称为sgn(类型)然后调用它将

为sgn(x)(6个字符),与( x <0)(5(或3个)字符)。所以它b / b
必须有一个char名称才能定义这样的

a的东西。


Rob。

-
http:/ /www.victim-prime.dsl.pipex.com/


这篇关于价值的标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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