Java tutorial
//package com.java2s; public class Main { public static final int GREEN_SHIFT = 8; public static final int LED_INTENSITY_LEVEL_COUNT = 4; public static int color2LedGreen(int color) { int green = (color >> GREEN_SHIFT) & 0xFF; int newGreen = (int) Math.round(green * (LED_INTENSITY_LEVEL_COUNT - 1) / (double) 0xFF); return newGreen; } }