long类型20位示例_Java Long类numberOfTrailingZeros()方法及示例

long类型20位示例

长类numberOfTrailingZeros()方法 (Long class numberOfTrailingZeros() method)

  • numberOfTrailingZeros() method is available in java.lang package.

    在java.lang包中提供了numberOfTrailingZeros()方法

  • numberOfTrailingZeros() method is used to returns the number of 0's bits following the rightmost one bit in the 2's complement denotation of the given parameter [value] of long type.

    numberOfTrailingZeros()方法用于返回long类型给定参数[value]的2的补码表示法中最右边一位之后的0位数。

  • numberOfTrailingZeros() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error.

    numberOfTrailingZeros()方法是一个静态方法,也可以使用类名进行访问,如果我们尝试使用类对象访问该方法,那么也不会出错。

  • numberOfTrailingZeros() method does not throw an exception at the time of trailing zeros.

    在尾随零时, numberOfTrailingZeros()方法不会引发异常。

Syntax:

句法:

    public static int numberOfTrailingZeros (long value);

Parameter(s):

参数:

  • long value – represents the long value to be parsed.

    long value –表示要解析的long值。

Return value:

返回值:

The return type of this method is int, it returns the integer value based on the following cases,

此方法的返回类型为int ,它基于以下情况返回整数值:

  • If the given argument is non-zero then, it returns the number of 0's bits followed the rightmost bit one bit in 2's complement of the given long value.

    如果给定的参数不为零,则返回给定long值的2的补码中,最右边的一位之后是0的位数。

  • Else, if the given argument is zero then, it returns the value 64 because it has no 1's bits in 2's complement of the given argument.

    否则,如果给定参数为零,则它将返回值64,因为在给定参数的2的补码中没有1的位。

Example:

例:

// Java program to demonstrate the example 
// of numberOfTrailingZeros (long value) method of Long class
public class NumberOfTrailingZerosOfLongClass {
public static void main(String[] args) {
long value1 = 1296;
long value2 = 0;
// It returns the string representation of the given unsigned 
// long value denoted by the argument in binary by calling
// Long.toBinaryString(value1)
System.out.println("Long.toBinaryString(value1): " + Long.toBinaryString(value1));
// It returns the string representation of the given unsigned 
// long value denoted by the argument in binary by calling
// Long.toBinaryString(value2) 
System.out.println("Long.toBinaryString(value2):" + Long.toBinaryString(value2));
// It returns the number of 0's bits following the leftmost side 
// one bit in the given argument 'value' by calling 
// Long.numberOfTrailingZeros(value1)
System.out.println("Long.numberOfTrailingZeros(value1): " + Long.numberOfTrailingZeros(value1));
// It returns the value 64 because the value of the given argument is zero 
System.out.println("Long.numberOfTrailingZeros(value2): " + Long.numberOfTrailingZeros(value2));
}
}

Output

输出量

Long.toBinaryString(value1): 10100010000
Long.toBinaryString(value2):0
Long.numberOfTrailingZeros(value1): 4
Long.numberOfTrailingZeros(value2): 64

翻译自: https://www.includehelp.com/java/long-class-numberoftrailingzeros-method-with-example.aspx

long类型20位示例

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/545733.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ActiveReports 9实战教程(1): 手把手搭建环境Visual Studio 2013 社区版

ActiveReports 9刚刚发布3天,微软就发布了 Visual Studio Community 2013 开发环境。Visual Studio Community 2013 提供完整功能的 IDE ,可开发 Windows、Android 和 iOS 应用。支持:C, Python, HTML5, JavaScript, 和 C#,VB, F# 语言的开发…

第 1-1 课:Java 程序是如何执行的?

了解任何一门语言的精髓都是先俯览其全貌,从宏观的视角把握全局,然后再深入每个知识点逐个击破,这样就可以深入而快速的掌握一项技能。同样学习 Java 也是如此,本节就让我们先从整体来看一下 Java 中的精髓。 Java 介绍 Java 诞…

linux——两个客户端之间实现聊天(TCP、单线程)

两个客户端实现聊天功能,那么服务器作转发信息的作用,客户端A先将信息发送到服务器,在由服务器将信息发送到客户端B,客户端B也是一样。客户端与服务器都应该有两个执行流,服务器的一个执行流不断的接收客户端A的信息并…

Java ClassLoader getSystemClassLoader()方法与示例

ClassLoader类getSystemClassLoader()方法 (ClassLoader Class getSystemClassLoader() method) getSystemClassLoader() method is available in java.lang package. getSystemClassLoader()方法在java.lang包中可用。 getSystemClassLoader() method is used to find the Sys…

zabbix邮件通知,短信通知配置详解

一、使用邮件发送报警1、前提条件是zabbix我们已经安装完成2、在官网我们下载msmtp的文件http://sourceforge.net/projects/msmtp/files/msmtp/1.4.32/msmtp-1.4.32.tar.bz2/download tar xf msmtp-1.4.32.tar.bz2 cd msmtp-1.4.32 ./configure--prefix/usr/local/msmtp make m…

关于怎么获取jsp的web站点的目录问题

发布了自己的web站点之后,想要访问站点文件夹下的某个文本文件,但是却不知道怎么找到文件根目录,一直尝试总是找不到文件……好不容易在网上翻了堆代码找到两句我现在急用的……so//根目录路径的获取System.out.println(request.getSession()…

开篇词:如何轻松获得 Offer

你好,我是王磊,某上市公司技术研发经理,前奇虎 360 员工,有着 10 余年的编程工作经验,目前主要负责新员工技术面试和构建企业技术架构的相关事宜。随着面试过的人数增加,我发现面试者们暴露出了技术方面的很多问题,为了让更多面试者少走一些弯路,也为了让企业能招到合适…

Java类类getGenericSuperclass()方法及示例

类类getGenericSuperclass()方法 (Class class getGenericSuperclass() method) getGenericSuperclass() method is available in java.lang package. getGenericSuperclass()方法在java.lang包中可用。 getGenericSuperclass() method is used to return the Type denoting th…

linux——客户端服务器文件传输

实现文件传输并不难,只需用fopen、fread、fwrite、fclose这几个函数对文件操作即可。文本文件就不说了,我们就已下图为例。 我们先来看看这个图片文件里装的是什么,我们以notpad打开这个图片,结果如下,是一堆乱码。 …

Android第二十五期 - 猜歌小游戏

代码已经整理好了,如下效果图:地址:http://yunpan.cn/cArkdixh5NbpQ 提取码 9300转载于:https://blog.51cto.com/liangxiao/1579433

第 1-2 课:你不知道的基础数据类型和包装类 + 面试题

基本数据类型 Java 基础数据按类型可以分为四大类:布尔型、整数型、浮点型、字符型,这四大类包含 8 种基础数据类型。 布尔型:boolean整数型:byte、short、int、long浮点型:float、double字符型:char 八种…

TomCat JDK环境变量

TomCat安装之前要安装JDK,安装完之后添加环境变量;变量名:Java_Home 变量值: D:\jdk 1.6 变量名:Classpath 变量值: D:\jdk 1.6\jre\lib\rt.jar;.; 变量名:Path 变量值: D:\jdk 1.6\…

网络编程C/S模型怎样才能实现真正的聊天功能

学完socket编成后,就迫不及待地写一个简单的聊天程序,好在同学面前装装逼,毕竟外行看热闹。然而在自己的电脑上运行是毫无差错,发送接收都没有问题,然而将客户端的exe文件打包后发送给其他电脑上运行时程序死在了conne…

c++重载++运算符_C ++运算符重载| 查找输出程序| 套装3

c重载运算符Program 1: 程序1&#xff1a; #include <iostream>using namespace std;class Test {public:int A;Test(){A 0;}Test(int a){A a;}void print(){cout << A << " ";}};Test operator*(Test T1, Test T2){Test temp;temp.A T1.A * T…

将数据库表导入到solr索引

将数据库表导入到solr索引 编辑solrcofnig.xml添加处理器 <requestHandler name"/dataimport" class"org.apache.solr.handler.dataimport.DataImportHandler"><lst name"defaults"><str name"config">data-config…

第 1-4 课:Java 中的运算符和流程控制 + 面试题

算术运算符 Java 中的算法运算符,包括以下几种: 算术运算符名称举例+加法1+2=3-减法2-1=1*乘法2*3=6/除法24/8=3%求余24%7=3++自增1int i=1;i++--自减1int i=1;i--我们本文要重点讲的是 “++” 和 “--”,其他的算术运算符相对比较简单直观,本文就不花精力去讲解了,之所以…

p标题/p能设置字体的大小和颜色

添加style <p style"color:red;font-size:16px;">标题</p>方法2&#xff1a;引入CSS<style type"text/css">.title{color:red;font-size:16px;}</style><body><p class"title">标题</p></body>…

scala中创建时间序列_如何从Scala中的序列中提取唯一元素?

scala中创建时间序列While storing data elements to a data structure or extracting raw data duplicate data might be included and this data decreases the efficiency of the code. So, eliminating duplicate data or extracting unique elements is important. 在将数…

获取u盘文件

功能&#xff1a;开机自启动&#xff0c;无dos窗口弹出&#xff0c;复制速度较快 缺点&#xff1a;面对杀软很无奈 #pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//屏蔽dos窗口 #include <stdio.h> #include <stdlib.h> #inc…

php中socket的使用

一、开启socket phpinfo();查看是否开启了socket扩展&#xff0c;否则在php.ini中开启。 二、服务器端代码的写法 <?php error_reporting(E_ALL); set_time_limit(0); //ob_implicit_flush();$address 127.0.0.1; $port 10005; //创建端口 if( ($sock socket_create(AF_…