bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Variable issue substr


From: Filimonov Vadim
Subject: Re: [bug-gawk] Variable issue substr
Date: Thu, 14 May 2015 14:24:59 +0300

Hello, Arnold.

Sorry for HTML.
Thank you. This hack with adding zero works fine.
But I really can't understand the root cause of problem.
When b1=9, in loop condition this variable converting to number.
So there must be i<=9. Why does i going out of the range?

14.05.2015, 13:57, "Aharon Robbins" <address@hidden>:
> Hello.
>
> Thank for the note. Please send plain text emails in the future instead
> of HTML.
>
> You are running into problems converting from string to number.
>
> Here is a corrected version of your second program:
>
>         BEGIN {
>                 a = "2345"
>                 b = "6789"
>                 a1 = substr(a, length(a), 1)
>                 b1 = substr(b, length(b), 1)
>                 print a1, b1
>                 for (i = a1 + 0; i <= b1 + 0; i++) {
>                         print i
>                 }
>         }
>
> Note the addition of zero to both a1 and b1 in order to force numeric
> comparison. Otherwise, i is converted from string to number and back to
> string each time around the loop, producing the results that you saw.
>
> Thanks,
>
> Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]