LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 08-28-2003, 07:27 AM   #1
Dimitris
LQ Newbie
 
Registered: Aug 2003
Posts: 13

Rep: Reputation: 0
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,
 
Old 08-28-2003, 07:38 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
can you post your code or make it clearer what your trying to do
 
Old 08-28-2003, 08:11 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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.
 
Old 08-28-2003, 08:45 AM   #4
Dimitris
LQ Newbie
 
Registered: Aug 2003
Posts: 13

Original Poster
Rep: Reputation: 0
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
 
Old 08-28-2003, 03:39 PM   #5
Dimitris
LQ Newbie
 
Registered: Aug 2003
Posts: 13

Original Poster
Rep: Reputation: 0
Could somebody help please ?
 
Old 08-28-2003, 03:47 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Square fonts with CEDEGA? Spooky Linux - Games 1 05-14-2005 03:14 PM
square one - how do I make it go? linuxceptic Linux - Wireless Networking 3 02-04-2004 08:23 PM
Square mouse pointer ? d4d4n9 Mandriva 11 12-28-2003 08:44 AM
I had a Dumbass attack, and cleared my Root path variable Huddlebum Linux - General 3 11-16-2003 09:33 PM
square root problems - script Dimitris Programming 4 09-02-2003 11:05 PM


All times are GMT -5. The time now is 01:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration