Java Double Number Truncate truncate(double x)

Here you can find the source of truncate(double x)

Description

truncate

License

Open Source License

Declaration

static public int truncate(double x) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static public int truncate(double x) {
        int res;//www  .j a v  a2  s. c  o  m

        if (x > 255)
            res = 255;
        else if (x < 0)
            res = 0;
        else
            res = (int) x;

        return res;
    }
}

Related

  1. truncate(double oldVal, double newMin, double newMax)
  2. truncate(double value, double precision)
  3. truncate(double value, int precision)
  4. truncate(double value, int truncation)
  5. truncate(double x)
  6. truncate(double x, double gran)
  7. truncate(double[] arr, int m)
  8. truncate(final double value, final double min, final double max)
  9. truncate(final double value, final double precision)