Re: expression evaluation problem

2019-07-26 Thread L A Walsh
On 2019/07/25 11:15, Ilkka Virta wrote: > On 24.7. 21:43, L A Walsh wrote: > >> The important part for me is whether or not it is faster to perform >> 1 calculation, or 100. So which would be faster? In this case >> execution speed >> is more important than clarity. I consider that a

Re: expression evaluation problem

2019-07-25 Thread Ilkka Virta
On 24.7. 21:43, L A Walsh wrote: Does it improve execution time? That's more of a concern here than readability, since it is an expression fragment, it isn't meant to be understood in isolation. [...] The important part for me is whether or not it is faster to perform 1 calculation,

Re: expression evaluation problem

2019-07-25 Thread Greg Wooledge
On Thu, Jul 25, 2019 at 10:29:08AM -0700, L A Walsh wrote: > On 2019/07/24 11:49, Greg Wooledge wrote: > > $((expression)) > > > >The expression is treated as if it were within double quotes, > I didn't use $((...)), I'd put the whole thing in ((...)) which I hoped > would

Re: expression evaluation problem

2019-07-25 Thread L A Walsh
On 2019/07/24 11:49, Greg Wooledge wrote: > On Wed, Jul 24, 2019 at 11:43:11AM -0700, L A Walsh wrote: > >> Those aren't my variables. >> If you assign the integer attribute to a variable it isn't the same >> as when you don't. >> > > In this case it *is*, because everything is being fed

Re: expression evaluation problem

2019-07-24 Thread Greg Wooledge
On Wed, Jul 24, 2019 at 11:43:11AM -0700, L A Walsh wrote: > Those aren't my variables. > If you assign the integer attribute to a variable it isn't the same > as when you don't. In this case it *is*, because everything is being fed to an arithmetic command anyway. Simplifying the bug report as m

Re: expression evaluation problem

2019-07-24 Thread L A Walsh
On 2019/07/24 10:51, Greg Wooledge wrote: > On Wed, Jul 24, 2019 at 09:39:46AM -0700, L A Walsh wrote: > >> str='cf80' >> v=960 uxtra=1 c=0 >> > > Irrelevant alias shenanigans omitted. These are your variables. > Those aren't my variables. If you assign the integer attribute to a

Re: expression evaluation problem

2019-07-24 Thread Greg Wooledge
On Wed, Jul 24, 2019 at 09:39:46AM -0700, L A Walsh wrote: > str='cf80' > v=960 uxtra=1 c=0 Irrelevant alias shenanigans omitted. These are your variables. > # In evaluating this expression: > ((v = v | ( uxtra>=++c ? ((0x${str:2*c:2}) & 63) << (6*(uxtra-c)) : 0 ))) > > > I get 985 and not

expression evaluation problem

2019-07-24 Thread L A Walsh
shopt -o expand_aliases my=declare int='my -i' my str='cf80' int v=960 uxtra=1 c=0 # In evaluating this expression: ((v = v | ( uxtra>=++c ? ((0x${str:2*c:2}) & 63) << (6*(uxtra-c)) : 0 ))) I get 985 and not 960 as expected Which only happens when 'c' is 0 in the middle 'str' expression,