Last active
April 23, 2024 01:59
-
-
Save dewomser/284df918266fbcdd56761aae8743e23e to your computer and use it in GitHub Desktop.
Addieren, subtrahieren, multiplizieren und dividieen mit Bash. ein Einzeiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Addiert,Subtrahiert oder Multipliziert GANZE Zahlen. | |
# Beispiel: 17+4 [ENTER] | |
read -p "Zahl1[+-*]Zahl2: " z1 a z2;echo "$z1$a$z2=$((z1$az2))" | |
# | |
#oder | |
# | |
# Addiert,subtrahiert,multipliziert oder dividiert RATIONALE Zahlen. | |
# Je nach Einstellung der Bashumgebung für Dezimalzahlen ist das Komma ein Punkt | |
# Beispiel: 17.1+3.9 [ENTER] | |
read -r -p "Zahl1[+-*/^]Zahl2: " z1 a z2;echo "$z1$a$z2= $(echo "$z1$a$z2" | bc -l)" | |
# Hier gibts noch mehr infos: https://stackoverflow.com/questions/12722095/how-do-i-use-floating-point-arithmetic-in-bash |
Author
dewomser
commented
Dec 29, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment