This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Data Type/jdbc  RSS feed

 
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
Boost this thread!