LinuxQuestions.org
Review your favorite Linux distribution.
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, 06: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, 06:38 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

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

Rep: Reputation: 111Reputation: 111
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, 07: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, 02:39 PM   #5
Dimitris
LQ Newbie
 
Registered: Aug 2003
Posts: 13

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

Rep: Reputation: 79
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 02:14 PM
square one - how do I make it go? linuxceptic Linux - Wireless Networking 3 02-04-2004 07:23 PM
Square mouse pointer ? d4d4n9 Mandriva 11 12-28-2003 07:44 AM
I had a Dumbass attack, and cleared my Root path variable Huddlebum Linux - General 3 11-16-2003 08:33 PM
square root problems - script Dimitris Programming 4 09-02-2003 10:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:49 AM.

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
Open Source Consulting | Domain Registration