快速提问:\楼层(\log_2(ix)) [英] quick question: \floor(\log_2(ix))

查看:65
本文介绍了快速提问:\楼层(\log_2(ix))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果ix是
整数,那么实现此功能的最快方法是什么?我需要将ix转换为浮动吗?什么是编码此功能的最快方式?


谢谢,

--j

推荐答案

>如果ix是
整数,那么实现此函数的最快方法是什么。我需要将ix转换为浮动吗?什么是编写此函数的最快方法?
an integer. Would i need to convert ix to float? What is the
fastest way to code this function?




最快的方法是查找表格很大,可能无法获得
实现。

第二快(对于常见的32位整数)可能是16位查找表

等等:


int logInt [65536]; //应该正确初始化

....

if(ix& 0xffff0000)

返回logInt [ix>> 16] +16;

其他

返回logInt [ix& 0xffff];


Niels Dybdahl



The fastest way is a giant lookup table which maybe is impossible to
implement.
Second fastest (for common 32 bit integers) might be a 16 bit lookup table
and something like:

int logInt[65536]; // Should be initialized properly
....
if (ix & 0xffff0000)
return logInt[ix >> 16]+16;
else
return logInt[ix & 0xffff];

Niels Dybdahl




" John" <我们********** @ yahoo.com>在消息中写道

news:11 ********************** @ o13g2000cwo.googlegr oups.com ...

"John" <we**********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
如果ix是一个整数,实现此功能的最快方法是什么。
What is the fastest way to implement this function if ix is
an integer.




如果设计算作实施的一部分;,开始输入

你得到的第一个想法。如果设计确实_不计算作为

实施的一部分,请花一些时间找到最短的设计,

并快速输入。



If the design counts as a part of "implementing", just start typing
the first idea you get. If the design does _not_ count as a part of
"implementing", use some time to find the shortest design you can,
and type it in really quickly.


John写道:

如果ix是什么,实现这个功能的最快方法是什么?整数。我需要将ix转换为浮动吗?什么是编写此功能的最快方法?

What is the fastest way to implement this function if ix is
an integer. Would i need to convert ix to float? What is the
fastest way to code this function?




什么功能?当

显示消息时,许多系统都没有显示主题。


无论如何速度不是标准的关注点,取决于

关于使用的确切系统。因此它在clc中是偏离主题的。

也许在clc ++中,但无论如何都是不同的b / b $ b语言,不应该在那里和
这里。 F''ups设定。


-

"如果你想通过groups.google.com发布后续内容,请不要使用

破损的回复链接在文章的底部。点击

" show options"在文章的顶部,然后点击

回复在文章标题的底部。 - Keith Thompson



What function? Many systems do not show the subject when
displaying the message.

At any rate speed is not the concern of the standard, and depends
on the exact system in use. Thus it is off-topic in c.l.c.
Probably also in c.l.c++, but at any rate that is a different
language and things should not be crossposted between there and
here. F''ups set.

--
"If you want to post a followup via groups.google.com, don''t use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


这篇关于快速提问:\楼层(\log_2(ix))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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