Tabnine Logo
Long.toBinaryString
Code IndexAdd Tabnine to your IDE (free)

How to use
toBinaryString
method
in
java.lang.Long

Best Java code snippets using java.lang.Long.toBinaryString (Showing top 20 results out of 1,260)

origin: looly/hutool

/**
 * 获得数字对应的二进制字符串
 * 
 * @param number 数字
 * @return 二进制字符串
 */
public static String getBinaryStr(Number number) {
  if (number instanceof Long) {
    return Long.toBinaryString((Long) number);
  } else if (number instanceof Integer) {
    return Integer.toBinaryString((Integer) number);
  } else {
    return Long.toBinaryString(number.longValue());
  }
}
origin: stackoverflow.com

 public static void print(double d){
  System.out.println(Long.toBinaryString(Double.doubleToRawLongBits(d)));
}
origin: immutables/immutables

@Override
public String apply(Number input) {
 if (input instanceof Long) {
  return "0b" + Long.toBinaryString(input.longValue()) + "L";
 }
 if (input instanceof Integer) {
  return "0b" + Integer.toBinaryString(input.intValue());
 }
 throw new IllegalArgumentException("unsupported non integer or long " + input);
}
origin: stackoverflow.com

 float f = 0.27f;
double d2 = (double) f;
double d3 = 0.27d;

System.out.println(Integer.toBinaryString(Float.floatToRawIntBits(f)));
System.out.println(Long.toBinaryString(Double.doubleToRawLongBits(d2)));
System.out.println(Long.toBinaryString(Double.doubleToRawLongBits(d3)));
origin: smuyyh/BookReader

  /**
   * return binary string of bitbuf
   */
  public String toString() {
    String s = "00000000000000000000000000000000" + Long.toBinaryString(bitbuf);
    s = s.substring(s.length() - 32);
    return s.substring(0, 8) + " " + s.substring(8, 16)
        + " " + s.substring(16, 24) + " " + s.substring(24, 32)
        + " " + bitsLeft;
  }
}
origin: org.assertj/assertj-core

@Override
protected String toStringOf(Long l) {
 return toGroupedBinary(Long.toBinaryString(l), 64);
}
origin: hibernate/hibernate-orm

public static String toBinaryString(int value) {
  String formatted = Long.toBinaryString( value );
  StringBuilder buf = new StringBuilder( StringHelper.repeat( '0', 32 ) );
  buf.replace( 64 - formatted.length(), 64, formatted );
  return buf.toString();
}
origin: hibernate/hibernate-orm

  public static String toBinaryString(long value) {
    String formatted = Long.toBinaryString( value );
    StringBuilder buf = new StringBuilder( StringHelper.repeat( '0', 64 ) );
    buf.replace( 64 - formatted.length(), 64, formatted );
    return buf.toString();
  }
}
origin: org.assertj/assertj-core

protected String toStringOf(Double d) {
 return toGroupedBinary(Long.toBinaryString(Double.doubleToRawLongBits(d)), 64);
}
origin: prestodb/presto

@Override
public void writeLong(BlockBuilder blockBuilder, long value)
{
  try {
    toIntExact(value);
  }
  catch (ArithmeticException e) {
    throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Value (%sb) is not a valid single-precision float", Long.toBinaryString(value).replace(' ', '0')));
  }
  blockBuilder.writeInt((int) value).closeEntry();
}
origin: prestodb/presto

@Override
public void writeLong(BlockBuilder blockBuilder, long value)
{
  try {
    toIntExact(value);
  }
  catch (ArithmeticException e) {
    throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Value (%sb) is not a valid single-precision float", Long.toBinaryString(value).replace(' ', '0')));
  }
  blockBuilder.writeInt((int) value).closeEntry();
}
origin: qiurunze123/miaosha

/** 测试 */
public static void main(String[] args) {
  SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
  for (int i = 0; i < 1000; i++) {
    long id = idWorker.nextId();
    System.out.println(Long.toBinaryString(id));
    System.out.println(id);
  }
}
origin: CalebFenton/simplify

public static BuilderInstruction buildConstant(double value, int register) {
  long longBits = Double.doubleToLongBits(value);
  String binaryValue = Long.toBinaryString(longBits);
  BuilderInstruction result;
  if (binaryValue.endsWith(LAST_48_BITS_ZERO)) {
    result = new BuilderInstruction21lh(Opcode.CONST_WIDE_HIGH16, register, longBits);
  } else {
    result = new BuilderInstruction51l(Opcode.CONST_WIDE, register, longBits);
  }
  return result;
}
origin: apache/hive

private static String dumpRef(long ref) {
 return StringUtils.leftPad(Long.toBinaryString(ref), 64, "0") + " o="
   + Ref.getOffset(ref) + " s=" + Ref.getStateByte(ref) + " l=" + Ref.hasList(ref)
   + " h=" + Long.toBinaryString(Ref.getHashBits(ref));
}
origin: apache/kylin

static String toString(Collection<Long> cuboids) {
  StringBuilder buf = new StringBuilder();
  buf.append("[");
  for (Long l : cuboids) {
    if (buf.length() > 1)
      buf.append(",");
    buf.append(l).append("(").append(Long.toBinaryString(l)).append(")");
  }
  buf.append("]");
  return buf.toString();
}
origin: facebook/litho

@Test
public void testStableIdCalculation() {
 mLayoutOutput.setComponent(mTestComponent);
 long stableId =
   calculateLayoutOutputId(mLayoutOutput, LEVEL_TEST, OutputUnitType.CONTENT, SEQ_TEST);
 long stableIdSeq2 =
   calculateLayoutOutputId(
     mLayoutOutput, LEVEL_TEST + 1, OutputUnitType.CONTENT, SEQ_TEST + 1);
 assertThat(toBinaryString(stableId)).isEqualTo("100000001000000000000000001");
 assertThat(toBinaryString(stableIdSeq2)).isEqualTo("100000010000000000000000010");
}
origin: facebook/litho

@Test
public void testStableIdCalculation() {
 mVisibilityOutput.setComponent(mComponent);
 long stableId = calculateVisibilityOutputId(
   mVisibilityOutput,
   LEVEL_TEST,
   SEQ_TEST);
 long stableIdSeq2 = calculateVisibilityOutputId(
   mVisibilityOutput,
   LEVEL_TEST + 1,
   SEQ_TEST + 1);
 assertThat(toBinaryString(stableId)).isEqualTo("100000001000000000000000001");
 assertThat(toBinaryString(stableIdSeq2)).isEqualTo("100000010000000000000000010");
}
origin: facebook/litho

@Test
public void testStableIdForegroundType() {
 mLayoutOutput.setComponent(mTestComponent);
 mLayoutOutput.setId(
   calculateLayoutOutputId(mLayoutOutput, LEVEL_TEST, OutputUnitType.FOREGROUND, SEQ_TEST));
 long stableId = mLayoutOutput.getId();
 assertThat(toBinaryString(stableId)).isEqualTo("100000001100000000000000001");
}
origin: facebook/litho

@Test
public void testStableIdBackgroundType() {
 mLayoutOutput.setComponent(mTestComponent);
 mLayoutOutput.setId(
   calculateLayoutOutputId(mLayoutOutput, LEVEL_TEST, OutputUnitType.BACKGROUND, SEQ_TEST));
 long stableId = mLayoutOutput.getId();
 assertThat(toBinaryString(stableId)).isEqualTo("100000001010000000000000001");
}
origin: facebook/litho

@Test
public void testStableIdHostType() {
 mLayoutOutput.setComponent(mTestComponent);
 mLayoutOutput.setId(
   calculateLayoutOutputId(mLayoutOutput, LEVEL_TEST, OutputUnitType.HOST, SEQ_TEST));
 long stableId = mLayoutOutput.getId();
 assertThat(toBinaryString(stableId)).isEqualTo("100000001110000000000000001");
}
java.langLongtoBinaryString

Javadoc

Converts the specified long value into its binary string representation. The returned string is a concatenation of '0' and '1' characters.

Popular methods of Long

  • parseLong
    Parses the string argument as a signed long in the radix specified by the second argument. The chara
  • toString
    Returns a string representation of the first argument in the radix specified by the second argument.
  • valueOf
    Returns a Long object holding the value extracted from the specified String when parsed with the rad
  • longValue
    Returns the value of this Long as a long value.
  • <init>
    Constructs a newly allocated Long object that represents the long value indicated by the String para
  • intValue
    Returns the value of this Long as an int.
  • equals
    Compares this object to the specified object. The result is true if and only if the argument is not
  • hashCode
  • toHexString
    Returns a string representation of the longargument as an unsigned integer in base 16.The unsigned l
  • compareTo
    Compares this Long object to another object. If the object is a Long, this function behaves likecomp
  • compare
    Compares two long values numerically. The value returned is identical to what would be returned by:
  • doubleValue
    Returns the value of this Long as a double.
  • compare,
  • doubleValue,
  • decode,
  • numberOfLeadingZeros,
  • numberOfTrailingZeros,
  • bitCount,
  • signum,
  • reverseBytes,
  • shortValue

Popular in Java

  • Making http requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • putExtra (Intent)
  • setContentView (Activity)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now