How do I determine if a negative float is between two other negative numbers in Ruby
Why is it that if I do
-102.between?(-100,-105)
in Ruby, it returns false?
-102 is indeed between -100 and -105, correct?
I'm trying to do this with a longitude coordinate (which in my hemisphere will开发者_Python百科 be negative) so for example if:
ilong = -102.560
if ilong.between?(-100.000,-105.000) then utmzone = 10 end
puts utmzone
should return 10.
How do I accomplish this?
-Jim
-102 is between -100 and -105 but, the order you're specifying is backwards as -105 < -100 try:
-102.between?(-105, -100)
精彩评论