For most of these examples, you must specify a precision for the format as well in order to meet typical project requirements for the course!

Students may add to this page if they feel so inclined.

C

   1 printf( "%e\n", 0.003 );

Beware %g formatting, its precision field specifies the maximum number of digits to use. It will print $\frac{1}{2}$ as just 0.5.

C++

   1 std::cout << std::scientific << 0.003 << std::endl;

Java

   1 System.println( "%e" % 0.003 );

Other methods exist with DecimalFormat.

Python

   1 "%e" % 0.003
   2 "{:e}".format( 0.003 )
   3 format(0.003,'.4e')

Racket

   1 (~r 0.003 #:notation 'exponential #:precision '(= 4))

Assignments/ScientificNotation (last edited 2020-10-02 09:33:10 by khellman)