Calculating using let and expr
am 05.12.2007 00:21:14 von apogeusistemasHi:
Can You tell me how execute this arithmetic operations using expr and
let ??
number=16773
a=(((20480-(($number *8192)/1024)))
Thank You Masters !
Hi:
Can You tell me how execute this arithmetic operations using expr and
let ??
number=16773
a=(((20480-(($number *8192)/1024)))
Thank You Masters !
On 2007-12-04, apogeusistemas@gmail.com wrote:
>
> Can You tell me how execute this arithmetic operations using expr and
> let ??
>
>
> number=16773
> a=(((20480-(($number *8192)/1024)))
let is not standard, and expr is unnecessary:
a=$(( 20480 - ($number * 8192) / 1024 ))
--
Chris F.A. Johnson, author
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
apogeusistemas@gmail.com writes:
> Hi:
>
> Can You tell me how execute this arithmetic operations using expr and
> let ??
>
let? I don't know what command 'let' is.
>
> number=16773
> a=(((20480-(($number *8192)/1024)))
Try this:
number=16773
a=`expr 20480 - \( \( $number \* 8192 \) \/ 1024 \)`
On 04 Dec 2007 21:45:10 -0500, Maxwell Lol wrote:
> apogeusistemas@gmail.com writes:
>
>> Can You tell me how execute this arithmetic operations using expr and
>> let ??
>
> let? I don't know what command 'let' is.
A question for comp.lang.basic
apogeusistemas@gmail.com wrote:
>
> Can You tell me how execute this arithmetic operations using expr and
> let ??
>
>
> number=16773
> a=(((20480-(($number *8192)/1024)))
$ number=16773
$ let a=20480-$number*8192/1024
$ echo $a
-113704
--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
On 2007-12-05, Allodoxaphobia
>
>
> On 04 Dec 2007 21:45:10 -0500, Maxwell Lol wrote:
>> apogeusistemas@gmail.com writes:
>>
>>> Can You tell me how execute this arithmetic operations using expr and
>>> let ??
>>
>> let? I don't know what command 'let' is.
>
> A question for comp.lang.basic
I think ksh has "let" as an alternative way of writing arithmetic
expressions.
In article
Bill Marcum
>On 2007-12-05, Allodoxaphobia
>> On 04 Dec 2007 21:45:10 -0500, Maxwell Lol wrote:
>>> apogeusistemas@gmail.com writes:
>>>
>>>> Can You tell me how execute this arithmetic operations using expr and
>>>> let ??
>>>
>>> let? I don't know what command 'let' is.
>>
>> A question for comp.lang.basic
>
>I think ksh has "let" as an alternative way of writing arithmetic
>expressions.
Yes. I have a vague and possibly incorrect memory that the first ksh I used
had let but not (( )).
One use I've found for let is testing whether an expression is legal or not,
without producing an error message:
let "expression" 1 2>/dev/null || ...
The 1 ensures that if the expression is legal (and so let doesn't stop its
evaluations), let will give status 0; without that, it would give status 1 if
expression was legal but evaluated to 0.
John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/