Longs (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.util

## Class Longs

- java.lang.Object
- - org.bouncycastle.util.Longs

-     public class Longs
      extends java.lang.Object

  Utility methods and constants for longs.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BYTES`
    `static int` | `SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Longs()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `bitCount(long i)`
    `static int` | `bitLength(long i)`
    `static int` | `compare(long x, long y)`
    `static int` | `compareUnsigned(long x, long y)`
    `static long` | `divideUnsigned(long x, long y)`
    `static long` | `highestOneBit(long i)`
    `static long` | `lowestOneBit(long i)`
    `static int` | `numberOfLeadingZeros(long i)`
    `static int` | `numberOfTrailingZeros(long i)`
    `static long` | `parseUnsignedLong(java.lang.String s)`
    `static long` | `reverse(long i)`
    `static long` | `reverseBytes(long i)`
    `static long` | `rotateLeft(long i, int distance)`
    `static long` | `rotateRight(long i, int distance)`
    `static java.lang.Long` | `valueOf(long value)`
    `static void` | `xorTo(int len, long[] x, int xOff, long[] z, int zOff)` Deprecated. Use `Nat.xorTo64(int, long[], int, long[], int)` instead.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BYTES

          public static final int BYTES

      See Also:
        Constant Field Values

    - #### SIZE

          public static final int SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Longs

          public Longs()

  - ### Method Detail

    - #### bitCount

          public static int bitCount(long i)

    - #### bitLength

          public static int bitLength(long i)

    - #### compare

          public static int compare(long x,
                                    long y)

    - #### compareUnsigned

          public static int compareUnsigned(long x,
                                            long y)

    - #### divideUnsigned

          public static long divideUnsigned(long x,
                                            long y)

    - #### highestOneBit

          public static long highestOneBit(long i)

    - #### lowestOneBit

          public static long lowestOneBit(long i)

    - #### numberOfLeadingZeros

          public static int numberOfLeadingZeros(long i)

    - #### numberOfTrailingZeros

          public static int numberOfTrailingZeros(long i)

    - #### parseUnsignedLong

          public static long parseUnsignedLong(java.lang.String s)

    - #### reverse

          public static long reverse(long i)

    - #### reverseBytes

          public static long reverseBytes(long i)

    - #### rotateLeft

          public static long rotateLeft(long i,
                                        int distance)

    - #### rotateRight

          public static long rotateRight(long i,
                                         int distance)

    - #### valueOf

          public static java.lang.Long valueOf(long value)

    - #### xorTo

          public static void xorTo(int len,
                                   long[] x,
                                   int xOff,
                                   long[] z,
                                   int zOff)

      Deprecated. Use `Nat.xorTo64(int, long[], int, long[], int)` instead.