We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  1. Practice
  2. Linux Shell
  3. Bash
  4. Arithmetic Operations
  5. Discussions

Arithmetic Operations

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial
  • Tutorial

    You are viewing a single comment's thread. Return to all comments →

  • abhishektyagi 4 years ago+ 5 comments

    printf "%.3f"e"|bc)

    -15|
    ParentPermalink
    • gentunian 4 years ago+ 2 comments

      just avoid the scale.

      printf "%.3f" will be sufficient

      4|
      ParentPermalink
      • bewuethr 3 years ago+ 1 comment

        Avoiding scale defaults to scale=0, so that won't work.

        3|
        ParentPermalink
        • kamalraghav 3 years ago+ 1 comment

          then whats the use of setting precision in printf

          0|
          ParentPermalink
          • maciektr 1 month ago+ 0 comments

            It rounds the number got from bc to 3 decimal points. Bc does no rounding.

            0|
            ParentPermalink
      • deikensentsu 3 years ago+ 0 comments

        As @bewuethr mentions avoiding scale won't work, but if you used bc -l it would as this defaults to scale of 20.

        3|
        ParentPermalink
    • ashwinjkm713 3 years ago+ 0 comments

      thanks :)

      0|
      ParentPermalink
    • hardik_mehta 3 years ago+ 0 comments

      printf "%.3f\n" exp | bc -l)

      -2|
      ParentPermalink
    • ken_cristian 2 years ago+ 1 comment

      There is a $ before the parenthesis that is being interpreted in the comment

      printf "%.3f" $(echo $exp | bc -l)
      
      5|
      ParentPermalink
      • sjames2 1 year ago+ 0 comments

        Why do you need the "$" before the echo part?

        3|
        ParentPermalink
    • stillone 2 years ago+ 0 comments

      above command not able to write in STDOUT

      0|
      ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature