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

Implict Cast Narrowing Doubts

 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From web page


I know at line 3,it will have compiler error.
Why at line 6 is not given the compiler error...
float is 32 bit and long is 64 bit
so it's narrowing anf for for narrowing the implicit cat will work if the assigned value is compiler time constant..
But above the float l is assigned a run time value..then why it is not given error.. pls clarify
 
Bob CHOI
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Compilation error "loss of precision" on the last 2 lines, not any above! ???
 
Tommaso Nuccio
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

the last two lines are assignments, while the others before are simply modifications of the value itself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic