效率 [英] Efficiency

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

问题描述

对于十六进制转换,执行此操作更有效:


Printit是char,其低位表示要打印的半字节


cout<< " 0123456789ABCDEF" [Printit];


或:


const char hexdigits [17] =" 0123456789ABCDEF" ;


cout<< hexdigits [Printit];

或者不重要吗?


谢谢

Joe

for a hex conversion, Is it more efficient to do this :

Printit is the char whose low order bits represent the nibble to print

cout << "0123456789ABCDEF" [ Printit ] ;

or :

const char hexdigits [17] = "0123456789ABCDEF" ;

cout << hexdigits [ Printit ] ;
Or doesn''t it matter ?

Thanks
Joe

推荐答案

" js" < JB ****** @ lmco.com>在消息中写道

news:bf ********* @ cui1.lmms.lmco.com ...
"js" <jb******@lmco.com> wrote in message
news:bf*********@cui1.lmms.lmco.com...
进行十六进制转换,是否更多高效地做到这一点:

Printit是char,其低位代表打印的半字节

cout<< " 0123456789ABCDEF" [Printit];

或:

const char hexdigits [17] =" 0123456789ABCDEF" ;

cout<< hexdigits [Printit];
for a hex conversion, Is it more efficient to do this :

Printit is the char whose low order bits represent the nibble to print

cout << "0123456789ABCDEF" [ Printit ] ;

or :

const char hexdigits [17] = "0123456789ABCDEF" ;

cout << hexdigits [ Printit ] ;



还有第三种方法:

const char * hexdigits =" 0123456789ABCDEF" ;;


cout<< hexdigits [Printit];


这并不重要。使用对你来说更方便的那个。



-

Ioannis


*编程页面: http://www.noicys.freeurl.com

*备选网址1: http://run.to/noicys

*备选网址2: http://www.noicys .cjb.net


There is and a third method:
const char *hexdigits="0123456789ABCDEF";

cout << hexdigits [Printit];

It doesn''t really matter. Use the one that is more convenient to you.



--
Ioannis

* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net




" js" < JB ****** @ lmco.com>在消息中写道

news:bf ********* @ cui1.lmms.lmco.com ...

"js" <jb******@lmco.com> wrote in message
news:bf*********@cui1.lmms.lmco.com...
进行十六进制转换,是否更多高效地做到这一点:

Printit是char,其低位代表打印的半字节

cout<< " 0123456789ABCDEF" [Printit];

或:

const char hexdigits [17] =" 0123456789ABCDEF" ;

cout<< hexdigits [Printit];

或者不重要吗?


你懂了。如果有任何差异,它将在nano

秒内测量。过分关注''效率''是以考虑

为代价的更重要的因素,例如干净的设计和清晰的代码,是一种典型的新手特性。
>
谢谢
Joe
for a hex conversion, Is it more efficient to do this :

Printit is the char whose low order bits represent the nibble to print

cout << "0123456789ABCDEF" [ Printit ] ;

or :

const char hexdigits [17] = "0123456789ABCDEF" ;

cout << hexdigits [ Printit ] ;
Or doesn''t it matter ?
You got it. If there is any difference it will be measureable in nano
seconds. Excessively concern for ''efficiency'' at the cost of considering
more important factors, such as clean design and legible code, is a typical
newbie trait.

Thanks
Joe




john



john


js写道:
对于十六进制转换,执行此操作是否更有效:

Printit是char,其低位表示要打印的半字节

cout<< ; " 0123456789ABCDEF" [Printit];

或:

const char hexdigits [17] =" 0123456789ABCDEF" ;

cout<< hexdigits [Printit];

或者不重要吗?
for a hex conversion, Is it more efficient to do this :

Printit is the char whose low order bits represent the nibble to print

cout << "0123456789ABCDEF" [ Printit ] ;

or :

const char hexdigits [17] = "0123456789ABCDEF" ;

cout << hexdigits [ Printit ] ;
Or doesn''t it matter ?



这些完全一样。


但是,您可以通过测试每一个来找到自己。


These are exactly the same.

However, you could find out for yourself by testing each one.


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

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