This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Long -> float

 
Ransika deSilva
Ranch Hand
Posts: 524
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
According the exam guide I am using, it is possible to covert an long value to a float value. They explain the other conversion saying 'widening' which means a 32 bit data type hold a 16 bit data type and so on. But the explanation for my question is not given.
So could you please explain how this is possible. Don't you need a cast to convert a 64 bit long to a 32 but float?
Thank you....
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason this is considered a widening conversion is that the range of possible float values is larger than the range of possible long values. Yes, you can lose precision in converting from long to float, but you don't lose "magnitude," so they decided to allow this conversion without a cast.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic