All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bretty.console.table.Precision Maven / Gradle / Ivy

Go to download

An extensible Java library to build stylish Excel-like tables, which can be converted into a single string with all table formats preserved.

The newest version!
/*
 * Copyright (c) 2015 SUN XIMENG (Nathaniel). All rights reserved.
 */

package io.bretty.console.table;

/**
 * The {@code Precision} enum represents the number of places after 
 * the decimal point in a decimal number.
 * @author nathaniel
 *
 */

public enum Precision {
	
	ZERO(0), ONE(1), TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6), SEVEN(7), EIGHT(
			8), NINE(9);


	private int precision;

	private Precision(int p) {
		this.precision = p;
	}

	protected String format(double n) {
		String f = "%." + this.precision + "f";
		return String.format(f, n);
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy