LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   root square / two solutions - one variable (https://www.linuxquestions.org/questions/programming-9/root-square-two-solutions-one-variable-86540/)

Dimitris 08-28-2003 06:27 AM

root square / two solutions - one variable
 
Hello,

I have two questions :) :

1)
I put the square in a variable x
when it gets solved it echos the result x=-1+1 for example

How can I make it show them in two different variables ?

2)
I make it solve a simple equation with random numbers.
Most of times the result is decimal but it shows it as an integer.
How to make that variable to hold decimals too ? I guess It's very simple but I couldn't find it in some manuals I have.

Thanks alot for your help!
Have a nice day,

kev82 08-28-2003 06:38 AM

can you post your code or make it clearer what your trying to do

Hko 08-28-2003 07:11 AM

Re: root square / two solutions - one variable
 
Quote:

Originally posted by Dimitris
How to make that variable to hold decimals too ? I guess It's very simple but I couldn't find it in some manuals I have.
Use double instead of int.

Dimitris 08-28-2003 07:45 AM

2)It's bash scripting.... I can use double ?

1) I mean a sqrt(4) gives two results. -2+2 . The result get's in one variable. I want each in a variable not both in one

Thanks

Dimitris 08-28-2003 02:39 PM

Could somebody help please ?

david_ross 08-28-2003 02:47 PM

Try this (where $SQRT is the complete variable)
one=`echo $SQRT | cut -d"+" -f 1`
two=`echo $SQRT | cut -d"+" -f 2`


All times are GMT -5. The time now is 06:03 AM.