- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Floating-point conversion characters in Java
Floating-point conversion characters include the following.
Character | Description |
---|---|
%e | decimal number in computerized scientific notation |
%E | decimal number in computerized scientific notation |
%f | decimal number |
%g | based on computerized scientific notation or decimal format, |
%G | based on computerized scientific notation or decimal format, |
Example
public class Demo { public static void main(String[] args) throws Exception { System.out.printf("Integer conversions...
"); System.out.printf( "Integer: %d
", 889 ); System.out.printf( "Negative Integer: %d
", -78 ); System.out.printf( "Octal: %o
", 677 ); System.out.printf( "Hexadecimal: %x
", 56 ); System.out.printf( "Hexadecimal: %X
", 99 ); System.out.printf("
Floating-point conversions...
"); System.out.printf( "%e
", 29567457.78 ); System.out.printf( "%E
", 34567457.89 ); System.out.printf( "%f
", 69874789.11 ); System.out.printf( "%g
", 7567579.38 ); System.out.printf( "%G
", 4766757.67 ); } }
Output
Integer conversions... Integer: 889 Negative Integer: -78 Octal: 1245 Hexadecimal: 38 Hexadecimal: 63 Floating-point conversions... 2.956746e+07 3.456746E+07 69874789.110000 7.56758e+06 4.76676E+06
- Related Articles
- Integral conversion characters in Java
- Floating-point hexadecimal in Java
- Conversion characters for date in Java
- Conversion characters for time in Java
- Format floating point number in Java
- Floating point operators and associativity in Java
- Format floating point with Java MessageFormat
- Apply modulus operator to floating-point values in Java
- Java program to multiply given floating point numbers
- Java Program to Multiply Two Floating-Point Numbers
- Floating Point Operations and Associativity in C, C++ and Java
- Floating point comparison in C++
- C++ Floating Point Manipulation
- Signed floating point numbers
- Fixed Point and Floating Point Number Representations

Advertisements