• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Representing floating point literals in hexidecimal format

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Consider the following assignment statement:
float float_REF = 0x1ef
How can one tell if the "f" above is part of the hexidecimal literal or if it is indicating that the floating point literal is of type float.
Thanks!
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compare the literals 0x1f and 1f
The compiler has to decide whether 0x1f is of type int or type float. A literal of type int can optionally start with 0x. A literal of type float cannot.
The compiler has to decide whether 1f is of type int or type float. A literal of type float ends with f. A literal of type int never ends with f.
It seems the compiler chooses the type that will work over the type that will not work.
[ July 07, 2003: Message edited by: Marlene Miller ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic