安卓log.e函数打印示例_C ++中带示例的log2()函数

news/2024/7/19 15:20:52 标签: c++, python, java, javascript, js

安卓log.e函数打印示例

C ++ log2()函数 (C++ log2() function)

log2() function is a library function of cmath header, it is used to get the binary logarithm (the base-2 logarithm) of the given value. It accepts a value (float, double, or long double) and returns the binary logarithm.

log2()函数cmath标头的库函数,用于获取给定值的二进制对数(以2为底的对数)。 它接受一个值( float , double或long double )并返回二进制对数。

Syntax of log2() function:

log2()函数的语法:

C++11:

C ++ 11:

     double log2 (double x);
      float log2 (float x);
long double log2 (long double x);
     double log2 (T x);

Parameter(s):

参数:

  • x – represents the value whose binary logarithm to be found.

    x –表示要找到其二进制对数的值。

Return value:

返回值:

It returns the binary logarithm of the given value x.

它返回给定值x的二进制对数。

Note:

注意:

  • If the given value is negative, it causes a domain error.

    如果给定值为负,则将导致域错误。

  • If the given value is zero, it may cause a pole error.

    如果给定值为零,则可能导致极点错误。

Example:

例:

    Input:
    float x = 2.0f
    
    Function call:
    log2(x);
    
    Output:
    1

C ++代码演示log2()函数的示例 (C++ code to demonstrate the example of log2() function)

// C++ code to demonstrate the example of
// log2() function

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    float x = 0.0f;

    x = 10.0f;
    cout << "log2(" << x << "): " << log2(x) << endl;

    x = 2.0f;
    cout << "log2(" << x << "): " << log2(x) << endl;

    x = 20.0f;
    cout << "log2(" << x << "): " << log2(x) << endl;

    x = -10.4f;
    cout << "log2(" << x << "): " << log2(x) << endl;

    x = 0.0f;
    cout << "log2(" << x << "): " << log2(x) << endl;

    x = 100.6f;
    cout << "log2(" << x << "): " << log2(x) << endl;

    return 0;
}

Output

输出量

log2(10): 3.32193
log2(2): 1
log2(20): 4.32193
log2(-10.4): nan
log2(0): -inf
log2(100.6): 6.65249

Reference: C++ log2() function

参考: C ++ log2()函数

翻译自: https://www.includehelp.com/cpp-tutorial/log2-function-with-example.aspx

安卓log.e函数打印示例


http://www.niftyadmin.cn/n/1254140.html

相关文章

php mysql存多维数组_REDIS存取PHP多维数组

REDIS数据库其实与mysql数据库在很多的用法上是一样的&#xff0c;今天 我们要介绍的是REDIS存取PHP多维数组的示例&#xff0c;如果有需要可以和小编一起来学学。PHP数组实际上是哈希表&#xff0c;Redis似乎不支持二维数组&#xff0c;但是可以使用hmset把PHP数组保存为hash类…

java点击上下箭头增减_用上下箭头标记数据增减

有这样一组销售数据&#xff0c;C列是每个月的销售额与销售平均值的比较情况&#xff1a;这种带上下箭头的样式&#xff0c;是使用了Excel的自定义格式&#xff0c;可以随数据变化自动改变箭头朝向和字体颜色。其实实现这样的效果并不难。选中C2:C10单元格区域&#xff0c;按Ct…

java workerqueue框架_一文总结线程池框架结构体系

原标题&#xff1a;一文总结线程池框架结构体系前面几篇文章分析了线程的主要实现&#xff0c;今天来整体总结以下他们。总览图直接上总结的总览图&#xff0c;如下图&#xff1a;如果看过前几篇文章应该基本能够看懂这张总结图&#xff0c;可能在单独的一篇文章里弄懂了一个知…

php的加法_菜鸟PHP加法递增运算法1+2+3+4+5................

/*12333664101051515621217282883636945451055......*/------------------------------下面还可以简化&#xff0c;我的思考太笨了这个是我第一次写的。$a1;//结果$c2;//循环次数while ($c<10){$b$c; //把C的值赋值给B &#xff0c;这个都是多余的$a$a$c;//实现ab结果赋值…

php 截取图片像素,php Imagick获取图片RGB颜色值

很多图片站点都会根据用户上传的图片检索出图片的主要颜色值&#xff0c;然后在通过颜色搜索相关的图片。之前按照网上的方法将图片缩放(或者马赛克)然后遍历每个像素点,然后统计处RGB次数最多的值,这做法效率太低而且取到的RGB值不够精确。之后才发现使用Imagick的quantizeIma…

python列表当堆栈_在Python中使用列表作为堆栈

python列表当堆栈First of all, we must aware with the Stack - the stack is a linear data structure that works on LIFO mechanism i.e. Last In First Out (that means Last inserted item will be removed (popped) first). 首先&#xff0c;我们必须了解堆栈 - 堆栈是一…

python 示例_带有示例的Python列表sort()方法

python 示例列表sort()方法 (List sort() Method) sort() method is used to sort the list elements in the ascending and descending order, the method is called with this list (whose elements to be sorted) and accept some optional parameters (explained below und…

php里的switch,PHP中Switch语句的运用

PHP中Switch语句的运用引导语&#xff1a;PHP 是一种 HTML 内嵌式的语言&#xff0c;是一种在服务器端执行的嵌入HTML文档的脚本语言&#xff0c;语言的风格有类似于C语言&#xff0c;被广泛地运用。以下是小编整理的PHP中Switch语句的运用&#xff0c;欢迎参考阅读!switch 语句…