Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright 2012-04-26 Werner Randelshofer
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.monte.media.math
Class IntMath

    java.lang.Object
      org.monte.media.math.IntMath

    public class IntMath

extends java.lang.Object

Utility class for integer arithmetic.

Version:
  1.2 2011-08-28 Adds scm(long,long).
  1.1 2009-12-27 Adds gcd(long,long).
  1.0 2002-05-01
Author:
  Werner Randelshofer

Constructor Summary
`IntMath()` Creates a new instance of IntMath

Method Summary
`static int` | `gcd(int a, int b)` Returns an int whose value is the greatest common divisor of `abs(a)` and `abs(b)`.
`static long` | `gcd(long a, long b)` Returns a long whose value is the greatest common divisor of `abs(a)` and `abs(b)`.
`static void` | `main(java.lang.String[] args)`
`static int` | `reverseBits(int a)` Reverses all 32 bits of the provided integer value.
`static int` | `reverseBits(int a, int numBits)` Reverses specified number of bits of the provided integer value.
`static int` | `scm(int a, int b)` Returns an int whose value is the smallest common multiple of `abs(a)` and `abs(b)`.
`static long` | `scm(long a, long b)` Returns an int whose value is the smallest common multiple of `abs(a)` and `abs(b)`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### IntMath

    public IntMath()

  Creates a new instance of IntMath

Method Detail

### gcd

    public static int gcd(int a,
                          int b)

  Returns an int whose value is the greatest common divisor of `abs(a)` and `abs(b)`. Returns 0 if `a==0 && b==0`.

  Parameters:
    `a` - value with with the GCD is to be computed.
    `b` - value with with the GCD is to be computed.
  Returns:
    `GCD(a, b)`

### gcd

    public static long gcd(long a,
                           long b)

  Returns a long whose value is the greatest common divisor of `abs(a)` and `abs(b)`. Returns 0 if `a==0 && b==0`.

  Parameters:
    `a` - value with with the GCD is to be computed.
    `b` - value with with the GCD is to be computed.
  Returns:
    `GCD(a, b)`

### scm

    public static int scm(int a,
                          int b)

  Returns an int whose value is the smallest common multiple of `abs(a)` and `abs(b)`. Returns 0 if `a==0 || b==0`.

  Parameters:
    `a` - value with with the SCM is to be computed.
    `b` - value with with the SCM is to be computed.
  Returns:
    `SCM(a, b)`

### scm

    public static long scm(long a,
                           long b)

  Returns an int whose value is the smallest common multiple of `abs(a)` and `abs(b)`. Returns 0 if `a==0 || b==0`.

  Parameters:
    `a` - value with with the SCM is to be computed.
    `b` - value with with the SCM is to be computed.
  Returns:
    `SCM(a, b)`

### reverseBits

    public static int reverseBits(int a)

  Reverses all 32 bits of the provided integer value.

### reverseBits

    public static int reverseBits(int a,
                                  int numBits)

  Reverses specified number of bits of the provided integer value.

  Parameters:
    `a` - The number.
    `numBits` - The number of bits (must be between 1 and 32).

### main

    public static void main(java.lang.String[] args)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright 2012-04-26 Werner Randelshofer
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD