Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How int of Float.POSITIVE_INFINITY in Integer.MAX_VALUE?

 
Prashant Neginahal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How int of Float.POSITIVE_INFINITY in Integer.MAX_VALUE?
I mean ,
(int)Float.POSITIVE_INFINITY==Integer.MAX_VALUE gives true....?
Prashant
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't that answered here?
- Peter
 
Harry Kong
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you cast Float.POSITIVE_INFINITY down to int it will be masked to Integer.MAX_VALUE. And Float.NEGATIVE_INFINITY will be masked to Integer.MIN_VALUE. And Float.NaN will be masked to 0. This also works for Double and Long.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic