Java Number Range Create RangeConvert(float start, float end, float newStart, float newEnd, float value)

Here you can find the source of RangeConvert(float start, float end, float newStart, float newEnd, float value)

Description

Range Convert

License

Open Source License

Declaration

public static float RangeConvert(float start, float end, float newStart, float newEnd, float value) 

Method Source Code

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

public class Main {
    public static float RangeConvert(float start, float end, float newStart, float newEnd, float value) {
        if (value < start || value > end) {
            System.err.println("Value was outside initial range.");
            return value;
        }//from  w  ww.  jav  a2s .com
        double scale = (double) (newEnd - newStart) / (end - start);
        return (float) (newStart + ((value - start) * scale));
    }
}

Related

  1. range(long start, long end)
  2. range(String field, int start, int end)
  3. range(String input[], int beginIndex, int endIndex)
  4. range(String second, String first)
  5. range(T val, T min, T max)