Convert a float to 16.16 fixed-point representation : Float « Date Type « Android






Convert a float to 16.16 fixed-point representation

    
//package edu.dhbw.andobjviewer.util;

// Much of this is adapted from the beartronics FP lib
 class FixedPointUtils {
  public static final int ONE = 0x10000;
  
  /**
   * Convert a float to  16.16 fixed-point representation
   * @param val The value to convert
   * @return The resulting fixed-point representation
   */
  public static int toFixed(float val) {
    return (int)(val * 65536F);
  }

}

   
    
    
    
  








Related examples in the same category

1.Convert a 16.16 fixed-point value to floating point
2.Random and Roundup
3.Is Long or double
4.calculate NormDiff
5.DecimalFormat, Maximum Fraction Digits
6.Format Distance
7.Gives the fractional part of a number
8.Close to a value
9.Value equals in a range, and ensure value inside a range
10.scale, round Number
11.Returns the smallest power of two that is greater than