Add two doubles on bash The 2019 Stack Overflow Developer Survey Results Are InHow to sum a bash array of numbers (some in scientific notation)?How do I add an if statement (regarding punctuation in a word) to this bash scriptSum up a given slice of elements in an array (bash)Wrong output in comparing floatsUnix command to return maximum float value out of two after subtractionAdd '.0' to single-digit integersawk in solaris 5.8 / get value from two fields/linesAddition of two floating numbers using shell scriptPassing multiple arguments to sudo within functionawk way to add numbers in line fieldshow to add two numbers together using bash

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

What is preventing me from simply constructing a hash that's lower than the current target?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

Ubuntu Server install with full GUI

What is this sharp, curved notch on my knife for?

The phrase "to the numbers born"?

How come people say “Would of”?

Can you cast a spell on someone in the Ethereal Plane, if you are on the Material Plane and have the True Seeing spell active?

Loose spokes after only a few rides

What do these terms in Caesar's Gallic Wars mean?

Why doesn't UInt have a toDouble()?

If my opponent casts Ultimate Price on my Phantasmal Bear, can I save it by casting Snap or Curfew?

Getting crown tickets for Statue of Liberty

Why can't wing-mounted spoilers be used to steepen approaches?

ELI5: Why they say that Israel would have been the fourth country to land a spacecraft on the Moon and why they call it low cost?

Can there be female White Walkers?

Can a flute soloist sit?

Why doesn't shell automatically fix "useless use of cat"?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Why does the nucleus not repel itself?

What force causes entropy to increase?

Button changing its text & action. Good or terrible?

How to quickly solve partial fractions equation?

A female thief is not sold to make restitution -- so what happens instead?



Add two doubles on bash



The 2019 Stack Overflow Developer Survey Results Are InHow to sum a bash array of numbers (some in scientific notation)?How do I add an if statement (regarding punctuation in a word) to this bash scriptSum up a given slice of elements in an array (bash)Wrong output in comparing floatsUnix command to return maximum float value out of two after subtractionAdd '.0' to single-digit integersawk in solaris 5.8 / get value from two fields/linesAddition of two floating numbers using shell scriptPassing multiple arguments to sudo within functionawk way to add numbers in line fieldshow to add two numbers together using bash



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm trying to add two doubles



y1=0.17580197E-01
y2=0.11979236E-02
sum=`echo $y1+$y2 | bc -l`


the above script gives me sum = -2.704405652. How do i resolve this issue?










share|improve this question









New contributor




Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Related: How to sum a bash array of numbers (some in scientific notation)?

    – steeldriver
    Apr 8 at 13:45











  • Thanks. Didn't know its different for scientific notation

    – Black Heart
    Apr 8 at 13:50

















0















I'm trying to add two doubles



y1=0.17580197E-01
y2=0.11979236E-02
sum=`echo $y1+$y2 | bc -l`


the above script gives me sum = -2.704405652. How do i resolve this issue?










share|improve this question









New contributor




Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Related: How to sum a bash array of numbers (some in scientific notation)?

    – steeldriver
    Apr 8 at 13:45











  • Thanks. Didn't know its different for scientific notation

    – Black Heart
    Apr 8 at 13:50













0












0








0








I'm trying to add two doubles



y1=0.17580197E-01
y2=0.11979236E-02
sum=`echo $y1+$y2 | bc -l`


the above script gives me sum = -2.704405652. How do i resolve this issue?










share|improve this question









New contributor




Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm trying to add two doubles



y1=0.17580197E-01
y2=0.11979236E-02
sum=`echo $y1+$y2 | bc -l`


the above script gives me sum = -2.704405652. How do i resolve this issue?







bash awk numeric-data bc






share|improve this question









New contributor




Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Apr 8 at 14:11









Jeff Schaller

45k1164147




45k1164147






New contributor




Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 8 at 13:41









Black HeartBlack Heart

31




31




New contributor




Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Black Heart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Related: How to sum a bash array of numbers (some in scientific notation)?

    – steeldriver
    Apr 8 at 13:45











  • Thanks. Didn't know its different for scientific notation

    – Black Heart
    Apr 8 at 13:50

















  • Related: How to sum a bash array of numbers (some in scientific notation)?

    – steeldriver
    Apr 8 at 13:45











  • Thanks. Didn't know its different for scientific notation

    – Black Heart
    Apr 8 at 13:50
















Related: How to sum a bash array of numbers (some in scientific notation)?

– steeldriver
Apr 8 at 13:45





Related: How to sum a bash array of numbers (some in scientific notation)?

– steeldriver
Apr 8 at 13:45













Thanks. Didn't know its different for scientific notation

– Black Heart
Apr 8 at 13:50





Thanks. Didn't know its different for scientific notation

– Black Heart
Apr 8 at 13:50










2 Answers
2






active

oldest

votes


















0














You can do it with awk with this command:



sum=`echo|awk -v y1=$y1 -v y2=$y2 'print y1+y2'`


As suggested in comment awk can be rewritten on this way (to avoid echo)



sum=`awk -v y1=$y1 -v y2=$y2 'BEGIN print y1+y2'`





share|improve this answer

























  • Worked. Thank you so much

    – Black Heart
    Apr 8 at 13:50











  • @BlackHeart, welcome. If you are fine with the answer you can upvote and/or accept it :)

    – Romeo Ninov
    Apr 8 at 13:51






  • 1





    You can change the block to BEGIN{... and save the echo :)

    – mickp
    Apr 8 at 14:36


















0














Try this,



echo "$y1 $y2" | awk 'print $1+$2'
0.0187781


Just print the two values separated by space and add the first two fields with awk






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Black Heart is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511233%2fadd-two-doubles-on-bash%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can do it with awk with this command:



    sum=`echo|awk -v y1=$y1 -v y2=$y2 'print y1+y2'`


    As suggested in comment awk can be rewritten on this way (to avoid echo)



    sum=`awk -v y1=$y1 -v y2=$y2 'BEGIN print y1+y2'`





    share|improve this answer

























    • Worked. Thank you so much

      – Black Heart
      Apr 8 at 13:50











    • @BlackHeart, welcome. If you are fine with the answer you can upvote and/or accept it :)

      – Romeo Ninov
      Apr 8 at 13:51






    • 1





      You can change the block to BEGIN{... and save the echo :)

      – mickp
      Apr 8 at 14:36















    0














    You can do it with awk with this command:



    sum=`echo|awk -v y1=$y1 -v y2=$y2 'print y1+y2'`


    As suggested in comment awk can be rewritten on this way (to avoid echo)



    sum=`awk -v y1=$y1 -v y2=$y2 'BEGIN print y1+y2'`





    share|improve this answer

























    • Worked. Thank you so much

      – Black Heart
      Apr 8 at 13:50











    • @BlackHeart, welcome. If you are fine with the answer you can upvote and/or accept it :)

      – Romeo Ninov
      Apr 8 at 13:51






    • 1





      You can change the block to BEGIN{... and save the echo :)

      – mickp
      Apr 8 at 14:36













    0












    0








    0







    You can do it with awk with this command:



    sum=`echo|awk -v y1=$y1 -v y2=$y2 'print y1+y2'`


    As suggested in comment awk can be rewritten on this way (to avoid echo)



    sum=`awk -v y1=$y1 -v y2=$y2 'BEGIN print y1+y2'`





    share|improve this answer















    You can do it with awk with this command:



    sum=`echo|awk -v y1=$y1 -v y2=$y2 'print y1+y2'`


    As suggested in comment awk can be rewritten on this way (to avoid echo)



    sum=`awk -v y1=$y1 -v y2=$y2 'BEGIN print y1+y2'`






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 8 at 15:01

























    answered Apr 8 at 13:48









    Romeo NinovRomeo Ninov

    7,00732129




    7,00732129












    • Worked. Thank you so much

      – Black Heart
      Apr 8 at 13:50











    • @BlackHeart, welcome. If you are fine with the answer you can upvote and/or accept it :)

      – Romeo Ninov
      Apr 8 at 13:51






    • 1





      You can change the block to BEGIN{... and save the echo :)

      – mickp
      Apr 8 at 14:36

















    • Worked. Thank you so much

      – Black Heart
      Apr 8 at 13:50











    • @BlackHeart, welcome. If you are fine with the answer you can upvote and/or accept it :)

      – Romeo Ninov
      Apr 8 at 13:51






    • 1





      You can change the block to BEGIN{... and save the echo :)

      – mickp
      Apr 8 at 14:36
















    Worked. Thank you so much

    – Black Heart
    Apr 8 at 13:50





    Worked. Thank you so much

    – Black Heart
    Apr 8 at 13:50













    @BlackHeart, welcome. If you are fine with the answer you can upvote and/or accept it :)

    – Romeo Ninov
    Apr 8 at 13:51





    @BlackHeart, welcome. If you are fine with the answer you can upvote and/or accept it :)

    – Romeo Ninov
    Apr 8 at 13:51




    1




    1





    You can change the block to BEGIN{... and save the echo :)

    – mickp
    Apr 8 at 14:36





    You can change the block to BEGIN{... and save the echo :)

    – mickp
    Apr 8 at 14:36













    0














    Try this,



    echo "$y1 $y2" | awk 'print $1+$2'
    0.0187781


    Just print the two values separated by space and add the first two fields with awk






    share|improve this answer



























      0














      Try this,



      echo "$y1 $y2" | awk 'print $1+$2'
      0.0187781


      Just print the two values separated by space and add the first two fields with awk






      share|improve this answer

























        0












        0








        0







        Try this,



        echo "$y1 $y2" | awk 'print $1+$2'
        0.0187781


        Just print the two values separated by space and add the first two fields with awk






        share|improve this answer













        Try this,



        echo "$y1 $y2" | awk 'print $1+$2'
        0.0187781


        Just print the two values separated by space and add the first two fields with awk







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 8 at 13:52









        msp9011msp9011

        4,60544167




        4,60544167




















            Black Heart is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Black Heart is a new contributor. Be nice, and check out our Code of Conduct.












            Black Heart is a new contributor. Be nice, and check out our Code of Conduct.











            Black Heart is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511233%2fadd-two-doubles-on-bash%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

            Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

            Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.