# Re: IP to Country (#139)

**URL:** <https://www.ruby-forum.com/t/re-ip-to-country-139/114841>\
**Category:** Ruby\
**Created:** [September 18, 2007, 12:37am UTC](https://www.ruby-forum.com/t/re-ip-to-country-139/114841 "2007-09-18T00:37:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@steve\_d](https://www.ruby-forum.com/u/steve_d)\
**Post date:** [September 18, 2007, 12:37am UTC](https://www.ruby-forum.com/t/re-ip-to-country-139/114841/1 "2007-09-18T00:37:17Z")

</div>

> I changed to while low \< high, and also the walking backwards failed  
> when reading the first line (btw, Steve, won’t your solution also fail  
> for that case?).

Yea it seems that mine will loop forever if you give an invalid ip  
address that evalutes to less than 0. Changing to ‘low \< high’ seems to  
fix that. Also it incorrectly reports nil instead of no country on  
0.0.0.0. This is all running on the stock csv file (with comments),  
haven’t tried it at all on a modified file.

- steve
