LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 04-28-2010, 11:15 AM   #1
onesikgypo
Member
 
Registered: Jun 2008
Posts: 56

Rep: Reputation: 15
How can i subtract two non-real (aka decimal'd) numbers via bash


Hi,

I just need to perform a simple operation of subtracting two numbers - that aren't whole numbers, i.e 200.56 - 67.24

attempting to use expr i merely get "expr: non-numeric argument"

Any assistance would be greatly appreciated.

Thanks
 
Old 04-28-2010, 11:21 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Code:
echo | awk '{print 200.56 - 67.24}'
or

Code:
echo '200.56 - 67.24' | bc
 
Old 04-28-2010, 11:45 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Semantics police here....
Those are real numbers---they are just not integers. ("real" is typically the opposite of "imaginary"---the latter being some product of sqrt(-1))

My favorite real-time calculator is now Python
 
Old 04-28-2010, 11:55 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by pixellany View Post
Semantics police here....
Those are real numbers---they are just not integers. ("real" is typically the opposite of "imaginary"---the latter being some product of sqrt(-1))

My favorite real-time calculator is now Python
Code:
perl -e 'print 9.8 - 7.6'
2.2
 
  


Reply



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
Format numbers using bash? KClaisse Programming 21 03-30-2015 06:47 AM
[SOLVED] Bash rounding up numbers with printf gary_in_springhill Programming 5 02-03-2010 01:34 AM
subtract total numbers of files from 2 directories Michael235 Linux - Newbie 2 03-28-2009 05:49 PM
LXer: Linux dark matter obscures real Firefox user numbers LXer Syndicated Linux News 0 12-03-2007 08:50 PM
post AIM sn's + ICQ numbers for real time help mp3province Linux - Software 4 04-10-2003 12:05 AM

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

All times are GMT -5. The time now is 03:35 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