Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Float argument

 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why line 1 gives error (too big of a float) while line 2 and 3 do not....
 
Greg Neef
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Float MAX_VALUE = 3.4028235E38 so the number you are entering is considered INFINITY even when it takes in the other two forms. I agree that it seems odd that it will take it as a string but not as a number.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't you think that asking the compiler to convert Strings into floats in order to check to see if it is too big a float might be a little too much to ask?
The last one is not too big because it isn't a float but rather a double. Moving a very large double to a float just turns the float into INFINITY.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic