Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

newbie question

 
Papa Miller
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the following example:

int a = 3;
double b;
b=a<=10?0.25:1.8;

I don't understand what the second line of code (double b) is doing? Is it doubling the value of 3, or does it have something to do with the data type, and b is assumed to be consecutive to 3?
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is declaring a variable b as type double, much like the first line of code declares the variable a as type int. The difference is that the variable a is initialized to the value 3, whereas the variable b is not initialized until line 3.
 
Papa Miller
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom, thanks
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm betting you'd enjoy reading this article!
 
Papa Miller
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedman-Hill wrote:I'm betting you'd enjoy reading this article!


thanks for the link, Sherriff!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic