Java Zero Format zeroToOne(long _min, long _max, long _value)

Here you can find the source of zeroToOne(long _min, long _max, long _value)

Description

zero To One

License

Apache License

Declaration

public static double zeroToOne(long _min, long _max, long _value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double zeroToOne(long _min, long _max, long _value) {
        if (_max == _min) {
            if (_value == _min) {
                return 0;
            }//from w  w  w.  ja v  a2s .  c o m
            if (_value > _max) {
                return Double.MAX_VALUE;
            }
            return -Double.MAX_VALUE;
        }
        return (_value - _min) / (double) (_max - _min);
    }

    public static double zeroToOne(double _min, double _max, double _value) {
        if (_max == _min) {
            if (_value == _min) {
                return 0;
            }
            if (_value > _max) {
                return Double.MAX_VALUE;
            }
            return -Double.MAX_VALUE;
        }
        return (_value - _min) / (_max - _min);
    }
}

Related

  1. zeroString(int length)
  2. zeroString(int value)
  3. zeroSupply(String value, int len)
  4. zeroThrough(int max)
  5. zeroToOne(float value, float min, float max)
  6. zeroToSpace(String s)
  7. zeroToStr(String fStr, String lStr)
  8. zeroUnPad(String s)
  9. zeroUnPad(String s)