BStorck

Demo of the accuracy of UNIX/Linux calculator dc.

Mar 28th, 2023 (edited)
956
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.12 KB | Source Code | 0 0
  1. #! /usr/bin/bash
  2. #
  3. # add100 1.0.1, 2023-03-28
  4. #
  5. # "Excel kann, wie alle Computerprogramme nicht richtig rechen. Rechne
  6. # einfach einhundert Zeilen: Die vorherige Zeile + 0.1 und schaue was
  7. # raus kommt. Da entsteht ein Fehler in der sechsten oder siebten
  8. # Kommastelle."
  9. #
  10. # Bernd Storck, https://www.facebook.com/BStLinux/
  11. #
  12.  
  13. dc_result=""
  14. dc_total=0
  15.  
  16. for i in $(seq 1 100);
  17. do
  18. # dc_total=$(dc -e "10 k $dc_total 0.1000000001 + p" | sed -E 's:^\.(.*)$:0\.\1:')
  19.   dc_total=$(dc -e "30 k $dc_total 0.10000000000000000000 + p" | sed -E 's:^\.(.*)$:0\.\1:')
  20.  
  21.   if (( i % 4 != 0 )) ; then
  22.     dc_result="${dc_result} - $dc_total"
  23.   else
  24.     dc_result="${dc_result} - $dc_total\n"
  25.   fi
  26. done
  27.  
  28. # echo -e "\nAddition mit dc (arbitrary precision calculator) unter Bodhi Linux 6.1.0:\n"
  29. echo -e "\n Addition with dc (arbitrary precision calculator) on Bodhi Linux 6.1.0:
  30.  
  31.   This demonstrates the accuracy of the dc calculator.  In this example, dc repeatedly adds 0.1
  32.   with an accuracy of 30 decimal places and outputs the result with 20 decimal places.
  33. "
  34. echo -e "$dc_result" | sed -E 's:^ - (.*)$:   \1:'
  35.  
  36. exit 0
  37.  
Advertisement
Comments
  • BESRGAMERPR122
    2 years
    1. --Get Gamepasses
    2. local gmppath = require(game:GetService("ReplicatedStorage").Framework.Modules.Client["5 | Gamepasses"])
    3. gmppath.Owns = function() return true end
    4.  
    5. --Fuze Pets (You Need 2.5k Gems)
    6. while wait() do
    7.     for i,v in pairs(game:GetService("Workspace")["__THINGS"].Pets:GetChildren()) do
    8.         local A_1 = {
    9.             [1] = {
    10.                 [1] = tostring(v.Name),
    11.                 [2] = tostring(v.Name),
    12.                 [3] = tostring(v.Name),
    13.                 [4] = tostring(v.Name),
    14.                 [5] = tostring(v.Name),
    15.                 [6] = tostring(v.Name),
    16.                 [7] = tostring(v.Name),
    17.                 [8] = tostring(v.Name),
    18.                 [9] = tostring(v.Name),
    19.                 [10] = tostring(v.Name),
    20.                 [11] = tostring(v.Name),
    21.                 [12] = tostring(v.Name)
    22.             }
    23.         }
    24.         local Event = game:GetService("Workspace")["THINGS"]["REMOTES"]["fuse pets"]
    25.         Event:InvokeServer(A_1)
    26.     end
    27. end
    28.  
Add Comment
Please, Sign In to add comment