1 / 6

CSE115: Introduction to Computer Science I

CSE115: Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall 645-4739 alphonce@buffalo.edu. Agenda. Announcements Cell phones / laptops off & away / Name signs out Last time floating point representations Today type conversions green UML class diagram tool demo.

benson
Download Presentation

CSE115: Introduction to Computer Science I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall 645-4739 alphonce@buffalo.edu

  2. Agenda • Announcements • Cell phones / laptops off & away / Name signs out • Last time • floating point representations • Today • type conversions • green UML class diagram tool demo

  3. mixing types in expressions • Operators such as +, -, * and / are overloaded: the same name has many different values + overloaded as String concatenation too! “Good” + “ ” + “morning!”  “Good morning!” • What happens in an expression which mixes values of different types? 5 + 2.5 = ???? 5 is coerced to its equivalent double value, 5.0: 5.0 + 2.5 = 7.5 • Type coercion happens only from “smaller” type to “larger” type (e.g. int double, not double  int)

  4. type casting • a type cast is a function which maps from a value in one type to a corresponding value in another type (i.e. it performs a type conversion) • form: (<type>) <value> • semantics: <value> mapped to <type> • example: (int) 2.1 maps to 2 • example: (int) 2.9 maps to 2

  5. type coercion • a coercion is an implicit type conversion • example • 3.5 + 4 evaluates to 7.5: • 4 is coerced to 4.0, then double addition takes place

  6. green UML demo • we did a short demo of the green UML tool • green • is a UML class diagram tool • does live round-tripping between code and diagram • is a plug-in to Eclipse • was developed by UB students (mostly undergrads) • e-mail me if you want to be part of green’s development team starting in the spring semester

More Related