Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Type/jdbc

 
j123
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to get and answer for how to store a twenty digit nuber with 2 decimals in java?
i would liket to print in in the screen
is there is any data type called Bigdigit?
I tried with double but its not working.,What should i do for that?
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by j123:
I would like to get and answer for how to store a twenty digit nuber with 2 decimals in java?
i would liket to print in in the screen
is there is any data type called Bigdigit?
I tried with double but its not working.,What should i do for that?

maybe java.math.BigDecimal?
Jamie
 
Yogen Vadnere
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Please try this...

double db = 12345678901234567890.12 ;
NumberFormat converter = NumberFormat.getInstance() ;
converter.setMaximumFractionDigits(2);
converter.setMinimumFractionDigits(2);
System.out.println( converter.format(db)) ;
 
Yogen Vadnere
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Please try this...

double db = 12345678901234567890.12 ;
NumberFormat converter = NumberFormat.getInstance() ;
converter.setMaximumFractionDigits(2);
converter.setMinimumFractionDigits(2);
System.out.println( converter.format(db)) ;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic