non numeric number to numeric
how can i change non numeric number to numeric?
for Example: 22.00 to 22 |
I think you mean decimal to integer and it depends on the programming language you are using, please show what you have done and a bit more info.
Just seen your post tally, come on! After 157posts you should know better. |
Sorry.
bash :) |
well BASH doesn't use decimals so I assume you are just using a string so just remove the decimal part like so:
Code:
keithhedger@LFSCerebro:~-> val=22.00 |
Quote:
(1) round to the nearest integer, or (2) truncate (throw away the fractional part)? Daniel B. Martin |
Thanks
|
To round to nearest integer use
Code:
keithhedger@LFSCerebro:~-> echo "scale=0;(22.00+0.5)/1"|bc -l |
Agree with danielbmartin; that was my first thought/qn too ..
|
Also: why th'hell use bash?! :doh:
The scripting-language built into bash is most-basic ... and really never intended to be used to do anything more than stringing a few commands together and poking at its command-line. If you want to do "real" things, use a "real" scripting language: Perl, Ruby, PHP, Python ... the list goes on and on. All of them probably already-installed on your machine. Any of which you can access by placing #!shebang line at the top of your script-file. The output of the command, when run, will not reveal what language-system is actually being used, and you will have the full power of that language ... doing the sort of things that that language was intended to do ... at your disposal. Frankly, even if you 'somehow monkey-wrench' Bash into producing an acceptable result, you'll be creating or perpetuating "an un-maintainable sack of ... :eek:." And there's plenty of that sort of thing on Planet Earth already! :) (And, BTW, I am intending that comment to have a purely technical, not personal, interpretation. "Given that you have the right tools for this job ready-at-hand, use the right tools for this job.") |
All times are GMT -5. The time now is 05:35 PM. |