The Artima Developer Community
Sponsored Link

Java Answers Forum
truncating

2 replies on 1 page. Most recent reply: Feb 17, 2003 6:38 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
gary davis

Posts: 1
Nickname: antonio142
Registered: Feb, 2003

truncating Posted: Feb 15, 2003 9:40 AM
Reply to this message Reply
Advertisement
Would like to know how to truncate numbers in Java programs.


Mike Penner

Posts: 16
Nickname: mikepenner
Registered: Jan, 2003

Re: truncating Posted: Feb 17, 2003 7:13 AM
Reply to this message Reply
Can you give an example of the kind of truncation you want to do? (e.g. truncate to a certain length, truncate to a certain number of decimal places, etc.).

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: truncating Posted: Feb 17, 2003 6:38 PM
Reply to this message Reply
double number = 12345.12345678;
String numberString = String.valueOf(number);
System.out.println("Truncate 3rd decimal" + numberString.substring(0,numberString.indexOf(".") + 3);

Flat View: This topic has 2 replies on 1 page
Topic: Availability of MDI form in java Previous Topic   Next Topic Topic: How to set Main to access methods

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use