Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Locale;

public class Main {
    public static float precision(int decimalPlace, float val) {
        if (Float.isNaN(val)) {
            return 0.0f;
        }

        String str = String.format(Locale.ENGLISH, "%." + decimalPlace + 'f', val);
        return Float.valueOf(str);

    }
}