in reply to Hex to decimal resulting in integer overflow
outputuse strict; my $hex = "24d0e803adb7"; for (0..16) { $hex = inc_hex($hex); print $hex, "\n"; } sub inc_hex { my @a = reverse map {hex} split '', $_[0]; $a[my $i = 0]++; while ($a[$i] == 16) { $a[$i] = 0; $a[++$i]++; } return join '', map {sprintf "%x", $_} reverse @a; }
24d0e803adb8 24d0e803adb9 24d0e803adba 24d0e803adbb 24d0e803adbc 24d0e803adbd 24d0e803adbe 24d0e803adbf 24d0e803adc0 24d0e803adc1 24d0e803adc2 24d0e803adc3 24d0e803adc4 24d0e803adc5 24d0e803adc6 24d0e803adc7 24d0e803adc8
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hex to decimal resulting in integer overflow (inc hex regex)
by tye (Sage) on Apr 01, 2011 at 22:50 UTC | |
by wind (Priest) on Apr 02, 2011 at 02:09 UTC | |
by tye (Sage) on Apr 02, 2011 at 02:54 UTC |