目标c /可可触摸中有什么样的对数函数/方法? [英] What kind of logarithm functions / methods are available in objective-c / cocoa-touch?

查看:154
本文介绍了目标c /可可触摸中有什么样的对数函数/方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过搜索logarithm + objective-c,但我所得到的是教师的数学测试页,或解释对数是什么)。

I've tried searching for logarithm + objective-c, but all I get is math test pages from teachers, or explanations what a logarithm is ;)

有一些测量,像83912.41234和其他人是32.94232。我需要把这个巨大的频谱压缩到0到100之间,32.94232将至少是大于2的东西,其中83912.41234将是接近100.所以我认为对数函数将是我的朋友在这里。

I've got some measurements that are like 83912.41234 and others are 32.94232. I need to press down this huge spectrum into something between 0 and 100, and that 32.94232 would habe to be at least something bigger than 2, where the 83912.41234 would be something near 100. So I think a logarithm function will be my friend here.

更新:
我通过快速打开(在Xcode中非常漂亮的命令:SHIFT + CMD + D)遇到math.h文件,有惊喜:

UPDATE: I've came across the math.h file through "Open Quickly" (very nice command in Xcode: SHIFT + CMD + D), and there, big surprise:

extern double log ( double );
extern float logf ( float );

extern double log10 ( double );
extern float log10f ( float );

extern double log2 ( double );
extern float log2f ( float );

extern double log1p ( double );
extern float log1pf ( float );

extern double logb ( double );
extern float logbf ( float );

但是:没有文字,没有注释。我不是一个数学家。因此,一些描述将是好的,即什么样的对数的情况下,曲线的外观,等等。所以任何伟大的链接,高度赞赏!

But: No text, no comments. I'm not such a math-freak. So some description would be good, i.e. what kind of logarithm for what case, how the curve looks like, etc... so any great links are highly appreciated!

推荐答案

此外,获取任意基数的对数:

Also, getting a logarithm with an arbitrary base:

float logx(float value, float base) 
{
   return log10f(value) / log10f(base);
}

这篇关于目标c /可可触摸中有什么样的对数函数/方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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