From ab210dce6f65e62c5eb2763cec1119f780135bcc Mon Sep 17 00:00:00 2001 From: Yucheng Hu Date: Sun, 16 Dec 2018 00:51:37 -0500 Subject: [PATCH] =?UTF-8?q?=E4=BD=8D=E6=93=8D=E4=BD=9C=E7=AC=A6=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lang/tutorial/tests/BitOperationTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/test/java/com/ossez/lang/tutorial/tests/BitOperationTest.java diff --git a/src/test/java/com/ossez/lang/tutorial/tests/BitOperationTest.java b/src/test/java/com/ossez/lang/tutorial/tests/BitOperationTest.java new file mode 100644 index 0000000000..eb570df0dd --- /dev/null +++ b/src/test/java/com/ossez/lang/tutorial/tests/BitOperationTest.java @@ -0,0 +1,36 @@ +package com.ossez.lang.tutorial.tests; + +import org.apache.commons.math3.util.FastMath; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author YuCheng + * + */ +public class BitOperationTest { + + private final static Logger logger = LoggerFactory.getLogger(BitOperationTest.class); + + /** + * 35 https://www.lintcode.com/problem/reverse-linked-list/description + */ + @Test + public void testInt2Bit() { + logger.debug("BEGIN"); + System.out.println(Integer.toBinaryString(5)); + System.out.println(Integer.toBinaryString(2)); + + System.out.println(Integer.toBinaryString(2 << 2)); + + System.out.println(Integer.parseInt(Integer.toBinaryString(2 << 2), 2)); + + System.out.println(5 / 3); + System.out.println(5 % 3); + FastMath.pow(2, 3); + + } + +}