CS Behind the Curtain (CS195 2003S)
Primary:
[Front Door]
[Current]
[Glance]
-
[Blurb]
[Disabilities]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Walker/Fall 2001]
[SamR]
Back to Predicates. On to Fundamental Types in C.
Held: Friday, 7 February 2003
Summary: Today we consider mechanisms for representing real numbers, particularly the IEEE standards.
Related Pages:
PrintFloatBits.java
, a program for exploring
the IEEE representation.Due
Assignments:
Notes:
Overview:
decimalpoint (except that it should be called the
binarypoint).
1.231 x 105.
/** * Print the bits in the represntation of a floating-point number * supplied on the command line. * * @author Samuel A. Rebelsky * @version 1.0 of February 2003 */ public class PrintFloatBits { /** * Grab the floating-point number from the command line, convert * it to bits, and print 'em out. */ public static void main(String[] args) { // (1) Convert the string to a float. float f = Float.parseFloat(args[0]); // (2) Convert the float to an integer with equivalent bit pattern. int i = Float.floatToIntBits(f); // (3) Conver the integer to a bit string (missing leading 0's). String bits = Integer.toBinaryString(i); // (4) Print out the result. System.out.println(args[0] + " is represented as " + bits); // (5) Be nice to the operating system. System.exit(0); } // main(String[]) } // class PrintFloatBits
Tuesday, 7 January 2003 [Samuel A. Rebelsky]
Friday, 7 February 2003 [Samuel A. Rebelsky]
Back to Predicates. On to Fundamental Types in C.
Primary:
[Front Door]
[Current]
[Glance]
-
[Blurb]
[Disabilities]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Walker/Fall 2001]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri May 2 14:20:21 2003.
The source to the document was last modified on Fri Feb 7 13:56:25 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS195/2003S/Outlines/outline.12.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby