Skip to content

Instantly share code, notes, and snippets.

@ihcomega56
Created June 16, 2015 11:32
Show Gist options
  • Select an option

  • Save ihcomega56/5b2d9f4a70859d4f3ba8 to your computer and use it in GitHub Desktop.

Select an option

Save ihcomega56/5b2d9f4a70859d4f3ba8 to your computer and use it in GitHub Desktop.
Java女子部勉強会201506〜BigDecimal#round()のふしぎ〜
56789 は、3桁以上あるかな?( ・ὢ・ )
1 は、3桁以上あるかな?( ・ὢ・ )
import java.math.BigDecimal;
import java.math.BigInteger;
/**
* Created by ihcomega56 on 2015/06/16.
*/
public class RoundSample {
public static void main(String... args) {
BigDecimal 丸まるくん = new BigDecimal("56.789");
BigDecimal 何も翁さん = new BigDecimal("0.0001");
BigInteger 丸まるくんの丸め対象 = 丸まるくん.unscaledValue();
BigInteger 何も翁さんの丸め対象 = 何も翁さん.unscaledValue();
System.out.println(String.valueOf(丸まるくんの丸め対象) + "\tは、3桁以上あるかな?( ・ὢ・ )");
System.out.println(String.valueOf(何も翁さんの丸め対象) + "\t\tは、3桁以上あるかな?( ・ὢ・ )");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment