Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(){
- double d = 12.2627;
- stdout.printf("%s\n",double_to_string_p(d,2));
- }
- public string double_to_string_p(double d, int precision){
- string s = d.to_string();
- stdout.printf("%s\n",s);
- string[] a = s.split(".");
- if(a.length < 2) return s;
- a[1] = a[1].substring(0,precision);
- return string.joinv(".",a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement