Can bash do floating-point arithmetic without using an external command? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
7
down vote

favorite
1













This question already has an answer here:



  • How to do integer & float calculations, in bash or other languages/frameworks?

    16 answers



I have read that bash can do integer arithmetic without using an external command, for example:



echo "$((3 * (2 + 1)))"


Can bash also do floating-point arithmetic without using an external command?







share|improve this question














marked as duplicate by Gilles bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Dec 24 '17 at 11:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    I don't believe so, but zsh does.
    – Jesse_b
    Dec 23 '17 at 20:14






  • 9




    Technically, since floating point arithmetic can be calculated (or approximated) with integers, the answer is "yes". But writing a software floating point library in shell script isn't really my idea of fun.
    – roaima
    Dec 23 '17 at 21:22










  • If you know how many bits you need for the fraction part of your numbers and the whole part, you just can calculate in these fractions as units. codegolf.stackexchange.com/a/61719/19214 shows a mandelbrot calculation in BASH with a resolution of 1/4096. Such a strategy can be applied to a wide range of everyday problems. The example was for PCG, so a bit cryptic, but the shift operations give a hint about how multiplication looks in this number representation.
    – yeti
    Dec 24 '17 at 1:26






  • 1




    ksh does floating point arithmetic and also has full support for all libm mathematical functions.
    – fpmurphy1
    Dec 24 '17 at 3:08







  • 1




    @yeti: That's fixed-point, not floating point. It's certainly worth pointing out as an alternate way to handle fractional values using mostly integer math, but floating point means there's an exponent stored explicitly so the relative precision is the same at any magnitude. (i.e. a constant number of significant figures instead of a constant number of places after the decimal.)
    – Peter Cordes
    Dec 24 '17 at 3:26














up vote
7
down vote

favorite
1













This question already has an answer here:



  • How to do integer & float calculations, in bash or other languages/frameworks?

    16 answers



I have read that bash can do integer arithmetic without using an external command, for example:



echo "$((3 * (2 + 1)))"


Can bash also do floating-point arithmetic without using an external command?







share|improve this question














marked as duplicate by Gilles bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Dec 24 '17 at 11:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    I don't believe so, but zsh does.
    – Jesse_b
    Dec 23 '17 at 20:14






  • 9




    Technically, since floating point arithmetic can be calculated (or approximated) with integers, the answer is "yes". But writing a software floating point library in shell script isn't really my idea of fun.
    – roaima
    Dec 23 '17 at 21:22










  • If you know how many bits you need for the fraction part of your numbers and the whole part, you just can calculate in these fractions as units. codegolf.stackexchange.com/a/61719/19214 shows a mandelbrot calculation in BASH with a resolution of 1/4096. Such a strategy can be applied to a wide range of everyday problems. The example was for PCG, so a bit cryptic, but the shift operations give a hint about how multiplication looks in this number representation.
    – yeti
    Dec 24 '17 at 1:26






  • 1




    ksh does floating point arithmetic and also has full support for all libm mathematical functions.
    – fpmurphy1
    Dec 24 '17 at 3:08







  • 1




    @yeti: That's fixed-point, not floating point. It's certainly worth pointing out as an alternate way to handle fractional values using mostly integer math, but floating point means there's an exponent stored explicitly so the relative precision is the same at any magnitude. (i.e. a constant number of significant figures instead of a constant number of places after the decimal.)
    – Peter Cordes
    Dec 24 '17 at 3:26












up vote
7
down vote

favorite
1









up vote
7
down vote

favorite
1






1






This question already has an answer here:



  • How to do integer & float calculations, in bash or other languages/frameworks?

    16 answers



I have read that bash can do integer arithmetic without using an external command, for example:



echo "$((3 * (2 + 1)))"


Can bash also do floating-point arithmetic without using an external command?







share|improve this question















This question already has an answer here:



  • How to do integer & float calculations, in bash or other languages/frameworks?

    16 answers



I have read that bash can do integer arithmetic without using an external command, for example:



echo "$((3 * (2 + 1)))"


Can bash also do floating-point arithmetic without using an external command?





This question already has an answer here:



  • How to do integer & float calculations, in bash or other languages/frameworks?

    16 answers









share|improve this question













share|improve this question




share|improve this question








edited Dec 24 '17 at 11:50









Gilles

506k12010031529




506k12010031529










asked Dec 23 '17 at 20:11









user267288

382




382




marked as duplicate by Gilles bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Dec 24 '17 at 11:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Gilles bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Dec 24 '17 at 11:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1




    I don't believe so, but zsh does.
    – Jesse_b
    Dec 23 '17 at 20:14






  • 9




    Technically, since floating point arithmetic can be calculated (or approximated) with integers, the answer is "yes". But writing a software floating point library in shell script isn't really my idea of fun.
    – roaima
    Dec 23 '17 at 21:22










  • If you know how many bits you need for the fraction part of your numbers and the whole part, you just can calculate in these fractions as units. codegolf.stackexchange.com/a/61719/19214 shows a mandelbrot calculation in BASH with a resolution of 1/4096. Such a strategy can be applied to a wide range of everyday problems. The example was for PCG, so a bit cryptic, but the shift operations give a hint about how multiplication looks in this number representation.
    – yeti
    Dec 24 '17 at 1:26






  • 1




    ksh does floating point arithmetic and also has full support for all libm mathematical functions.
    – fpmurphy1
    Dec 24 '17 at 3:08







  • 1




    @yeti: That's fixed-point, not floating point. It's certainly worth pointing out as an alternate way to handle fractional values using mostly integer math, but floating point means there's an exponent stored explicitly so the relative precision is the same at any magnitude. (i.e. a constant number of significant figures instead of a constant number of places after the decimal.)
    – Peter Cordes
    Dec 24 '17 at 3:26












  • 1




    I don't believe so, but zsh does.
    – Jesse_b
    Dec 23 '17 at 20:14






  • 9




    Technically, since floating point arithmetic can be calculated (or approximated) with integers, the answer is "yes". But writing a software floating point library in shell script isn't really my idea of fun.
    – roaima
    Dec 23 '17 at 21:22










  • If you know how many bits you need for the fraction part of your numbers and the whole part, you just can calculate in these fractions as units. codegolf.stackexchange.com/a/61719/19214 shows a mandelbrot calculation in BASH with a resolution of 1/4096. Such a strategy can be applied to a wide range of everyday problems. The example was for PCG, so a bit cryptic, but the shift operations give a hint about how multiplication looks in this number representation.
    – yeti
    Dec 24 '17 at 1:26






  • 1




    ksh does floating point arithmetic and also has full support for all libm mathematical functions.
    – fpmurphy1
    Dec 24 '17 at 3:08







  • 1




    @yeti: That's fixed-point, not floating point. It's certainly worth pointing out as an alternate way to handle fractional values using mostly integer math, but floating point means there's an exponent stored explicitly so the relative precision is the same at any magnitude. (i.e. a constant number of significant figures instead of a constant number of places after the decimal.)
    – Peter Cordes
    Dec 24 '17 at 3:26







1




1




I don't believe so, but zsh does.
– Jesse_b
Dec 23 '17 at 20:14




I don't believe so, but zsh does.
– Jesse_b
Dec 23 '17 at 20:14




9




9




Technically, since floating point arithmetic can be calculated (or approximated) with integers, the answer is "yes". But writing a software floating point library in shell script isn't really my idea of fun.
– roaima
Dec 23 '17 at 21:22




Technically, since floating point arithmetic can be calculated (or approximated) with integers, the answer is "yes". But writing a software floating point library in shell script isn't really my idea of fun.
– roaima
Dec 23 '17 at 21:22












If you know how many bits you need for the fraction part of your numbers and the whole part, you just can calculate in these fractions as units. codegolf.stackexchange.com/a/61719/19214 shows a mandelbrot calculation in BASH with a resolution of 1/4096. Such a strategy can be applied to a wide range of everyday problems. The example was for PCG, so a bit cryptic, but the shift operations give a hint about how multiplication looks in this number representation.
– yeti
Dec 24 '17 at 1:26




If you know how many bits you need for the fraction part of your numbers and the whole part, you just can calculate in these fractions as units. codegolf.stackexchange.com/a/61719/19214 shows a mandelbrot calculation in BASH with a resolution of 1/4096. Such a strategy can be applied to a wide range of everyday problems. The example was for PCG, so a bit cryptic, but the shift operations give a hint about how multiplication looks in this number representation.
– yeti
Dec 24 '17 at 1:26




1




1




ksh does floating point arithmetic and also has full support for all libm mathematical functions.
– fpmurphy1
Dec 24 '17 at 3:08





ksh does floating point arithmetic and also has full support for all libm mathematical functions.
– fpmurphy1
Dec 24 '17 at 3:08





1




1




@yeti: That's fixed-point, not floating point. It's certainly worth pointing out as an alternate way to handle fractional values using mostly integer math, but floating point means there's an exponent stored explicitly so the relative precision is the same at any magnitude. (i.e. a constant number of significant figures instead of a constant number of places after the decimal.)
– Peter Cordes
Dec 24 '17 at 3:26




@yeti: That's fixed-point, not floating point. It's certainly worth pointing out as an alternate way to handle fractional values using mostly integer math, but floating point means there's an exponent stored explicitly so the relative precision is the same at any magnitude. (i.e. a constant number of significant figures instead of a constant number of places after the decimal.)
– Peter Cordes
Dec 24 '17 at 3:26










2 Answers
2






active

oldest

votes

















up vote
13
down vote



accepted










No.



Bash cannot perform floating point arithmetic natively.




This is not what you're looking for but may help someone else:



Alternatives



  1. bc

bc allows floating point arithmetic, and can even convert whole numbers to floating point by setting the scale value. (Note the scale value only affects division within bc but a workaround for this is ending any formula with division by 1)



$ echo '10.1 / 1.1' | bc -l
9.18181818181818181818
$ echo '55 * 0.111111' | bc -l
6.111105
$ echo 'scale=4; 1 + 1' | bc -l
2
$ echo 'scale=4; 1 + 1 / 1' | bc -l
2.0000



  1. awk

awk is a programming language in itself, but is easily leveraged to perform floating point arithmetic in your bash scripts, but that's not all it can do!



echo | awk 'print 10.1 / 1.1'
9.18182
$ awk 'BEGINprint 55 * 0.111111'
6.11111
$ echo | awk 'print log(100)'
4.60517
$ awk 'BEGINprint sqrt(100)'
10


I used both echo piped to awk and a BEGIN to show two ways of doing this. Anything within an awk BEGIN statement will be executed before input is read, however without input or a BEGIN statement awk wouldn't execute so you need to feed it input.




  1. Perl

Another programming language that can be leveraged within a bash script.



$ perl -l -e 'print 10.1 / 1.1'
9.18181818181818
$ somevar="$(perl -e 'print 55 * 0.111111')"; echo "$somevar"
6.111105



  1. Python

Another programming language that can be leveraged within a bash script.



$ python -c 'print 10.1 / 1.1'
9.18181818182
$ somevar="$(python -c 'print 55 * 0.111111')"; echo "$somevar"
6.111105



  1. Ruby

Another programming language that can be leveraged within a bash script.



$ ruby -l -e 'print 10.1 / 1.1'
9.18181818181818
$ somevar="$(ruby -e 'print 55 * 0.111111')"; echo "$somevar"
6.111105





share|improve this answer


















  • 1




    and more alternatives by @Stéphane Chazelas unix.stackexchange.com/questions/40786/…
    – frams
    Dec 24 '17 at 3:38

















up vote
2
down vote













"Can bash also do floating-point arithmetic without using an external command?"



Nope.



robert@pip2:/tmp$ echo $((2.5 * 3))
bash: 2.5 * 3: syntax error: invalid arithmetic operator (error token is ".5 * 3")





share|improve this answer



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    13
    down vote



    accepted










    No.



    Bash cannot perform floating point arithmetic natively.




    This is not what you're looking for but may help someone else:



    Alternatives



    1. bc

    bc allows floating point arithmetic, and can even convert whole numbers to floating point by setting the scale value. (Note the scale value only affects division within bc but a workaround for this is ending any formula with division by 1)



    $ echo '10.1 / 1.1' | bc -l
    9.18181818181818181818
    $ echo '55 * 0.111111' | bc -l
    6.111105
    $ echo 'scale=4; 1 + 1' | bc -l
    2
    $ echo 'scale=4; 1 + 1 / 1' | bc -l
    2.0000



    1. awk

    awk is a programming language in itself, but is easily leveraged to perform floating point arithmetic in your bash scripts, but that's not all it can do!



    echo | awk 'print 10.1 / 1.1'
    9.18182
    $ awk 'BEGINprint 55 * 0.111111'
    6.11111
    $ echo | awk 'print log(100)'
    4.60517
    $ awk 'BEGINprint sqrt(100)'
    10


    I used both echo piped to awk and a BEGIN to show two ways of doing this. Anything within an awk BEGIN statement will be executed before input is read, however without input or a BEGIN statement awk wouldn't execute so you need to feed it input.




    1. Perl

    Another programming language that can be leveraged within a bash script.



    $ perl -l -e 'print 10.1 / 1.1'
    9.18181818181818
    $ somevar="$(perl -e 'print 55 * 0.111111')"; echo "$somevar"
    6.111105



    1. Python

    Another programming language that can be leveraged within a bash script.



    $ python -c 'print 10.1 / 1.1'
    9.18181818182
    $ somevar="$(python -c 'print 55 * 0.111111')"; echo "$somevar"
    6.111105



    1. Ruby

    Another programming language that can be leveraged within a bash script.



    $ ruby -l -e 'print 10.1 / 1.1'
    9.18181818181818
    $ somevar="$(ruby -e 'print 55 * 0.111111')"; echo "$somevar"
    6.111105





    share|improve this answer


















    • 1




      and more alternatives by @Stéphane Chazelas unix.stackexchange.com/questions/40786/…
      – frams
      Dec 24 '17 at 3:38














    up vote
    13
    down vote



    accepted










    No.



    Bash cannot perform floating point arithmetic natively.




    This is not what you're looking for but may help someone else:



    Alternatives



    1. bc

    bc allows floating point arithmetic, and can even convert whole numbers to floating point by setting the scale value. (Note the scale value only affects division within bc but a workaround for this is ending any formula with division by 1)



    $ echo '10.1 / 1.1' | bc -l
    9.18181818181818181818
    $ echo '55 * 0.111111' | bc -l
    6.111105
    $ echo 'scale=4; 1 + 1' | bc -l
    2
    $ echo 'scale=4; 1 + 1 / 1' | bc -l
    2.0000



    1. awk

    awk is a programming language in itself, but is easily leveraged to perform floating point arithmetic in your bash scripts, but that's not all it can do!



    echo | awk 'print 10.1 / 1.1'
    9.18182
    $ awk 'BEGINprint 55 * 0.111111'
    6.11111
    $ echo | awk 'print log(100)'
    4.60517
    $ awk 'BEGINprint sqrt(100)'
    10


    I used both echo piped to awk and a BEGIN to show two ways of doing this. Anything within an awk BEGIN statement will be executed before input is read, however without input or a BEGIN statement awk wouldn't execute so you need to feed it input.




    1. Perl

    Another programming language that can be leveraged within a bash script.



    $ perl -l -e 'print 10.1 / 1.1'
    9.18181818181818
    $ somevar="$(perl -e 'print 55 * 0.111111')"; echo "$somevar"
    6.111105



    1. Python

    Another programming language that can be leveraged within a bash script.



    $ python -c 'print 10.1 / 1.1'
    9.18181818182
    $ somevar="$(python -c 'print 55 * 0.111111')"; echo "$somevar"
    6.111105



    1. Ruby

    Another programming language that can be leveraged within a bash script.



    $ ruby -l -e 'print 10.1 / 1.1'
    9.18181818181818
    $ somevar="$(ruby -e 'print 55 * 0.111111')"; echo "$somevar"
    6.111105





    share|improve this answer


















    • 1




      and more alternatives by @Stéphane Chazelas unix.stackexchange.com/questions/40786/…
      – frams
      Dec 24 '17 at 3:38












    up vote
    13
    down vote



    accepted







    up vote
    13
    down vote



    accepted






    No.



    Bash cannot perform floating point arithmetic natively.




    This is not what you're looking for but may help someone else:



    Alternatives



    1. bc

    bc allows floating point arithmetic, and can even convert whole numbers to floating point by setting the scale value. (Note the scale value only affects division within bc but a workaround for this is ending any formula with division by 1)



    $ echo '10.1 / 1.1' | bc -l
    9.18181818181818181818
    $ echo '55 * 0.111111' | bc -l
    6.111105
    $ echo 'scale=4; 1 + 1' | bc -l
    2
    $ echo 'scale=4; 1 + 1 / 1' | bc -l
    2.0000



    1. awk

    awk is a programming language in itself, but is easily leveraged to perform floating point arithmetic in your bash scripts, but that's not all it can do!



    echo | awk 'print 10.1 / 1.1'
    9.18182
    $ awk 'BEGINprint 55 * 0.111111'
    6.11111
    $ echo | awk 'print log(100)'
    4.60517
    $ awk 'BEGINprint sqrt(100)'
    10


    I used both echo piped to awk and a BEGIN to show two ways of doing this. Anything within an awk BEGIN statement will be executed before input is read, however without input or a BEGIN statement awk wouldn't execute so you need to feed it input.




    1. Perl

    Another programming language that can be leveraged within a bash script.



    $ perl -l -e 'print 10.1 / 1.1'
    9.18181818181818
    $ somevar="$(perl -e 'print 55 * 0.111111')"; echo "$somevar"
    6.111105



    1. Python

    Another programming language that can be leveraged within a bash script.



    $ python -c 'print 10.1 / 1.1'
    9.18181818182
    $ somevar="$(python -c 'print 55 * 0.111111')"; echo "$somevar"
    6.111105



    1. Ruby

    Another programming language that can be leveraged within a bash script.



    $ ruby -l -e 'print 10.1 / 1.1'
    9.18181818181818
    $ somevar="$(ruby -e 'print 55 * 0.111111')"; echo "$somevar"
    6.111105





    share|improve this answer














    No.



    Bash cannot perform floating point arithmetic natively.




    This is not what you're looking for but may help someone else:



    Alternatives



    1. bc

    bc allows floating point arithmetic, and can even convert whole numbers to floating point by setting the scale value. (Note the scale value only affects division within bc but a workaround for this is ending any formula with division by 1)



    $ echo '10.1 / 1.1' | bc -l
    9.18181818181818181818
    $ echo '55 * 0.111111' | bc -l
    6.111105
    $ echo 'scale=4; 1 + 1' | bc -l
    2
    $ echo 'scale=4; 1 + 1 / 1' | bc -l
    2.0000



    1. awk

    awk is a programming language in itself, but is easily leveraged to perform floating point arithmetic in your bash scripts, but that's not all it can do!



    echo | awk 'print 10.1 / 1.1'
    9.18182
    $ awk 'BEGINprint 55 * 0.111111'
    6.11111
    $ echo | awk 'print log(100)'
    4.60517
    $ awk 'BEGINprint sqrt(100)'
    10


    I used both echo piped to awk and a BEGIN to show two ways of doing this. Anything within an awk BEGIN statement will be executed before input is read, however without input or a BEGIN statement awk wouldn't execute so you need to feed it input.




    1. Perl

    Another programming language that can be leveraged within a bash script.



    $ perl -l -e 'print 10.1 / 1.1'
    9.18181818181818
    $ somevar="$(perl -e 'print 55 * 0.111111')"; echo "$somevar"
    6.111105



    1. Python

    Another programming language that can be leveraged within a bash script.



    $ python -c 'print 10.1 / 1.1'
    9.18181818182
    $ somevar="$(python -c 'print 55 * 0.111111')"; echo "$somevar"
    6.111105



    1. Ruby

    Another programming language that can be leveraged within a bash script.



    $ ruby -l -e 'print 10.1 / 1.1'
    9.18181818181818
    $ somevar="$(ruby -e 'print 55 * 0.111111')"; echo "$somevar"
    6.111105






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 24 '17 at 0:47

























    answered Dec 23 '17 at 20:18









    Jesse_b

    10.5k22659




    10.5k22659







    • 1




      and more alternatives by @Stéphane Chazelas unix.stackexchange.com/questions/40786/…
      – frams
      Dec 24 '17 at 3:38












    • 1




      and more alternatives by @Stéphane Chazelas unix.stackexchange.com/questions/40786/…
      – frams
      Dec 24 '17 at 3:38







    1




    1




    and more alternatives by @Stéphane Chazelas unix.stackexchange.com/questions/40786/…
    – frams
    Dec 24 '17 at 3:38




    and more alternatives by @Stéphane Chazelas unix.stackexchange.com/questions/40786/…
    – frams
    Dec 24 '17 at 3:38












    up vote
    2
    down vote













    "Can bash also do floating-point arithmetic without using an external command?"



    Nope.



    robert@pip2:/tmp$ echo $((2.5 * 3))
    bash: 2.5 * 3: syntax error: invalid arithmetic operator (error token is ".5 * 3")





    share|improve this answer
























      up vote
      2
      down vote













      "Can bash also do floating-point arithmetic without using an external command?"



      Nope.



      robert@pip2:/tmp$ echo $((2.5 * 3))
      bash: 2.5 * 3: syntax error: invalid arithmetic operator (error token is ".5 * 3")





      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        "Can bash also do floating-point arithmetic without using an external command?"



        Nope.



        robert@pip2:/tmp$ echo $((2.5 * 3))
        bash: 2.5 * 3: syntax error: invalid arithmetic operator (error token is ".5 * 3")





        share|improve this answer












        "Can bash also do floating-point arithmetic without using an external command?"



        Nope.



        robert@pip2:/tmp$ echo $((2.5 * 3))
        bash: 2.5 * 3: syntax error: invalid arithmetic operator (error token is ".5 * 3")






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 23 '17 at 20:32









        mrflash818

        16117




        16117












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?