Re: Recomended tutoial(s) on doing arithmetic in Bash scripts
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, Mar 05, 2017 at 06:14:00PM +0000, GiaThnYgeia wrote:
> It is Sunday and I don't like Mondays
> tell me why
>
> tomas@tuxteam.de:
> > Hm. Neither expr nor bc are bash, they are "external" binaries. If you
> > want to do arithmetic in bash, there's $((...)):
> >
> > tomas@rasputin:~$ echo $(( (3+4)/3 ))
> > 2
>
> I see your 2 and raise you
> nosuchagency@bottomofthesea:~$ echo $(((3000000000+4000000000)/3))
> 2333333333
>
> Infinitely inaccurate digital systems
:-)
Try GNU Guile: it'll happily fill your computer's memory with long integers:
tomas@rasputin:~$ guile
GNU Guile 2.0.13.5-458ae
Copyright (C) 1995-2016 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> (expt 2 2)
$1 = 4
; aha: that's the function we're looking for ;-)
scheme@(guile-user)> (expt 2 400)
$2 = 2582249878086908589655919172003011874329705792829223512830659356540647622016841194629645353280137831435903171972747493376
regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAli8dgEACgkQBcgs9XrR2kZ6kQCfSApe0fBbLHYUjrM5o251Z1j8
ojUAniMceGWgFKkSfcndntQDrWyi9BIB
=/cuA
-----END PGP SIGNATURE-----
Reply to: