## Test decimal number

Test decimal number
# 1
07-31-2009
Test decimal number

Hi,

I would like test if a number is a decimal number or not
 francis_tom View Public Profile for francis_tom Find all posts by francis_tom
# 2
07-31-2009
one way
 jim mcnamara View Public Profile for jim mcnamara Find all posts by jim mcnamara
# 3
07-31-2009
Try...
\$0==\$0+0 checks that its a number(but not Hexadecimal) and match(\$0,0)!=1 checks its not octal.
 rakeshawasthi View Public Profile for rakeshawasthi Find all posts by rakeshawasthi
# 4
07-31-2009
Hi, i try something like this :
But it doesn't works..... Whatever value I put in nombre, it returns "la bas". I think I don't have the correct syntaxe to say " a string composed of blablabla.blablabla" (where blabla are digits)
I tried
Quote:
[*.*]
,
Quote:
{*.*}
and many other things, but it still don't works.

so is it possible to do what I want to do? If yes, could someone tell me the right way to write it?

regards
 Moumou View Public Profile for Moumou Find all posts by Moumou
# 5
07-31-2009
Sorry, i would like know , after a division , if result is a number integer or not,

( 300 and 301 are value)

echo 300 / 2 | bc -l
150.00000000000000000000
--> it 's ok

echo 301 / 2 |bc -l
150.50000000000000000000
--> it's ko
 francis_tom View Public Profile for francis_tom Find all posts by francis_tom
# 6
07-31-2009
Use pattern matching

if [ `echo \$num / 2 | bc -l | grep -c "[0-9]*\.00000000000000000000" ` = 1 ]
then
echo "OK"
else
echo "KO"
fi
 Niroj View Public Profile for Niroj Find all posts by Niroj
# 7
07-31-2009
Something like this?

 Franklin52 View Public Profile for Franklin52 Find all posts by Franklin52

Test Your Knowledge in Computers #1004
Difficulty: Medium
Hopper College at Caltech University was named in honor of Grace Hopper in 2017.
True or False?

## Zero padding a Number before and after a decimal place

Hi I was hoping someone could help me with a sed script I am trying to write? I am on a Mac running ElCapitan I have some text that I have converted from a pdf that I want to format into an xml file. In the file I have managed to delete all the text I do not need. The text I have left is...

## Sort Decimal number in UNIX

Hello Everyone, In one of my script, I would like to sort the decimal numbers. For e.g. If I have numbers like 1.0 1.1 1.2 2.0 2.1 3.0 4.0 5.0 6.0 7.0 7.1 7.10 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 I would like to sort them 1.0 1.1 1.2 2.0 2.1 3.0 4.0 5.0 6.0 7.0 7.1 7.2 7.3 7.4...

## Decimal number calculation problem

I have a below snippet of code from my perl script and its causing a problem when the output of \$lTAX is 0 (zero) its getting displayed as -0.00. I want output to be 0 not -0.00. Any help would be appreciated. #!/usr/bin/perl my \$lTotA = 50.94; my \$lVatA = 8.49; my \$lAllocD; my \$lAdjNr =...

## Matching a decimal number?

Hi everyone! Easy question for everyone. I'm trying to run a command line to find an exact match of a decimal number within a file. The number can be a positive OR negative number. For instance, if I want to find only the number -1 in the file that has: -17.6 -17 -16.3 -16.2 -15.7 -15.3...

## number of digits after decimal

Hi All, I have a file of decimal numbers, cat file1.txt 1.1382666907 1.2603107334 1.6118799297 24.4995857056 494.7632588468 560.7633734425 ..... I want to see the output as only 7 digits after decimal

## check if a decimal number is greater than zero

Hello, In my code I am checking to see if a variable that contains a decimal number is greater than 0 in the following manner: if do something fi However I am getting the error message (if \$i for the current iteration holds 9.6352) command 9.6352 is not found How can I rectify...

## if test for higher value between 2 decimal numbers

Hi I would like to test for a max number value. It may be a decimal so I know I have to pipe into bc. I just cannot get the syntax for this to work. I cannot get passed an error with the bracket - see below. Any help appreciated. Regards Ewan This works: /export/home/ewan> cat...

## Pattern to match decimal number and interger

Hi, i've a code if ((\$A && ((!(\$A =~ /^\d+\$/))))) { -- -- not a number } else { --- its number. } which matches for integer value, i need to modify that pattern where it matches decimal number with 2 decimal points and also integer value. for eg: values 10, 10.00. 0.1, 1 , 3 must...

## Add zero in decimal number

echo "scale=2; 282.73/640" | bc This will print .44 How to make the variable as 0.44