• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Sybex 1Z0-815, Chapter 2 - Writing Literals

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my honest opinion, the book should mention the default type when writing literals for decimal numbers: double

Source: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

The book only specifies the default type assumed by the compiler for integer numeric literals (int).
 
Marshal
Posts: 80629
471
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CK: Welcome to the Ranch
 
Cristina Kiss
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again,

Thank you !

I just wanted to point out that in Chapter 2 it is not explained in any way that floating-point numeric literals that appear in a piece of code are interpreted (default to) double.

Furthermore, Chapter 3 refers to this concept, which is a bit misleading:
" As you may remember from Chapter 2, floating-point literals are assumed to be double, unless postfixed with an f, as in 2.1f (Boyarsky, 20191119, p. 89)

Boyarsky, J., Selikoff, S.  (20191119). OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide [VitalSource Bookshelf version].  Retrieved from vbk://9781119584568

Always check citation for accuracy before use.
"

What do you guys think ?

Thanks,
Cristina.
 
author & internet detective
Posts: 42135
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Table 2.1 has an example of 123.45f.  Table 2.3  (page 53) has a a table with the default types. It lists 0.0 for both float and double. We intentionally don't cover 0.0f vs 0.0d there because we are trying to illustrate the principle of a floating vs integer type there. And we cover that a smaller type can be stored in a larger type. So looks good to me!
 
reply
    Bookmark Topic Watch Topic
  • New Topic