LinuxQuestions.org
Help answer threads with 0 replies.
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 07-28-2006, 05:27 AM   #1
gn00kie
Member
 
Registered: Jan 2006
Posts: 70

Rep: Reputation: 15
Convert float to integer in bash


Hi all,
I have a problem in one of my scripts. In one variable, I get a floating point value. Then I use -le to an Integer value. I get errors on my script as -le is only applicable to integers. How do I convert my floating point value to integer via a bash script? TIA.
 
Old 07-28-2006, 06:43 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
perhaps this can be a solution:
Code:
FLOAT=1234.0000
INT=${FLOAT/.*}
# or maybe
INT=${FLOAT/\.*}
 
Old 07-30-2006, 10:05 PM   #3
gn00kie
Member
 
Registered: Jan 2006
Posts: 70

Original Poster
Rep: Reputation: 15
thanks for the help mate...
 
  


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
Double/float to long integer bastl Programming 18 06-03-2006 09:24 AM
How to convert a float to its binary or hex representation in Python? zero79 Programming 1 09-01-2005 10:19 AM
How to convert a float to its binary or hex representation in Python? zero79 Linux - Software 1 08-29-2005 09:30 PM
count digits of a float || convert float to string nadroj Programming 6 07-11-2005 04:52 PM
can't convert o to FLoat in Java alaios Programming 4 04-24-2004 02:10 PM

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

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