Score:-1

how insert decimal number in ubuntu?

pg flag

How can I multiply by decimal numbers and get the result in decimal?? How can the code be modified to meet these two conditions? enter image description here

uz flag
Jos
Please read `man bc`.
jp flag
Dan
Please, don't use screenshots of code. Instead, paste your code into your question and format it as code by selecting it and clicking the `{}` icon (or the Ctrl+K shortcut).
hr flag
Related: [Bash only gives integer as output regardless of input when performing calculations](https://askubuntu.com/questions/1108328/bash-only-gives-integer-as-output-regardless-of-input-when-performing-calculatio)
Score:0
ck flag

You could call the desk-calculator program to do the arithmetic:

v1 = 3
pi = 3.14
$ echo "Area of Circle =" $(dc --expression="$pi $v1 * $v1 * p")
Area of Circle = 28.26

In case you aren't familiar with it, dc uses reverse-polish syntax:

  • stack $pi
  • stack $v1
  • replace the top two numbers with their product
  • stack $v1
  • replace the top two numbers with their product
  • print the top of the stack

These are equivalent expressions:

$ echo "Area of Circle =" $(dc --expression="$pi $v1 * $v1 * p")
Area of Circle = 28.26

$ echo "Area of Circle =" $(dc --expression="$pi $v1 2 ^ * p")
Area of Circle = 28.26

$ echo "Area of Circle =" $(dc --expression="$v1 2 ^ $pi * p")
Area of Circle = 28.26
Amany ahmad avatar
pg flag
when use this command>>> linux write: dc stack empty & pi: not found command
Ray Butterworth avatar
ck flag
@Amanyahmad, did you first set the values of *pi* and *v1*? Before doing the `echo …` line, try `echo $pi` and `echo $v1` to verify that they are set correctly. ¶ Also, make sure you are using the bash shell: `echo $SHELL` should print "/bin/bash".
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.