Here you can find the source of zeroToOne(long _min, long _max, long _value)
public static double zeroToOne(long _min, long _max, long _value)
//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); } }