10-31-2007
GREAT!!!
Now it works.
thanx to all, guyz.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to create a script that will read from a file two non-integer values (decimals) and add those values together. For example, I want to add 1.51 and -2.37 together and get the sum. Any ideas? Thanks! (2 Replies)
Discussion started by: limshady411
2 Replies
2. Shell Programming and Scripting
Hi all,
I have a issue... Is it possible to compare integer value with decimal value.
If it is not possible,then how can i compare 2 decimal values in born shell.thanks! (3 Replies)
Discussion started by: MARY76
3 Replies
3. Shell Programming and Scripting
Hi everyone,
I would like to know how to convert an integer to a string. for instance if i=1 i would like to creat a variable called constant1. i want to do this in a for loop so for each value of i, i create a new variable such as constant2, constant3,... and so on.
for i in 1 2 3
do ... (1 Reply)
Discussion started by: ROOZ
1 Replies
4. Shell Programming and Scripting
The shell mentioned below will show a warning if the page takes more than 6 seconds to load.
The problem is that myduration variable is not an integer. How do I convert it to integer?
myduration=$(curl http://192.168.50.1/mantisbt/view.php?id=1 -w %{time_total}) > /dev/null ; ] && echo... (3 Replies)
Discussion started by: shantanuo
3 Replies
5. UNIX for Dummies Questions & Answers
i need to do camparisions like the below.
For the case when first=10 and second=9.9 the scripts displays process failed.
I need to be able to convert the values to integer before doing the comparision.
Like 9.9 should be rounded over to 10 before doing comparision.
Please advice how can... (3 Replies)
Discussion started by: nehagupta
3 Replies
6. Shell Programming and Scripting
From strings stored in variables, I need to isolate and use the first numerical value contained within them. I will need to know how to produce an integer as well as a floating point decimal. It needs to work on any string regardless of what types of characters (if any) are preceding or following... (3 Replies)
Discussion started by: bradlecat
3 Replies
7. Shell Programming and Scripting
Using below command
awk 'NR==FNR{A=$1;next}
{sum+=($2*A)}END{OFMT="%20f";print int(sum)}' Market.txt Product.txt
answer:351770174.00000
how to convert this to 351770174.
when i try with below command i am getting different result.
awk 'NR==FNR{A=$1;next}... (3 Replies)
Discussion started by: katakamvivek
3 Replies
8. Shell Programming and Scripting
I have a function that is supposed to check for user processes and wait for 0 count before exiting the function. I am sure I have more than one issue in my code, but the stumbling block right now is that I am trying to convert the value of my variable from a string to integer.
process_count... (10 Replies)
Discussion started by: MIA651
10 Replies
9. Shell Programming and Scripting
Hi Experts,
Need your advice.
I have a csv file in which column value can contain two integer post decimal(like 1.00, 13.00,12.15, 2.43) or blank.
Tried the below code but not working.
awk -F "|" '{
if ($39 !~ /^+\.{2}$ || $39 != "") {print "165: Quantity decimal values are not correct... (2 Replies)
Discussion started by: as7951
2 Replies
10. Shell Programming and Scripting
Hi guys...
I am loving this integer maths thing.
64 bit systems are certainly easier than 32 bit, but hey, I don't intend to leave out my fav' platform.
Using one of the 'Brothers' methods, URL inside the code.
#!/bin/sh
#
# #!/usr/local/bin/dash
# e_constant.sh
# Brother's formula .
#... (2 Replies)
Discussion started by: wisecracker
2 Replies
BINDEC(3) 1 BINDEC(3)
bindec - Binary to decimal
SYNOPSIS
number bindec (string $binary_string)
DESCRIPTION
Returns the decimal equivalent of the binary number represented by the $binary_string argument.
bindec(3) converts a binary number to an integer or, if needed for size reasons, float.
bindec(3) interprets all $binary_string values as unsigned integers. This is because bindec(3) sees the most significant bit as another
order of magnitude rather than as the sign bit.
PARAMETERS
o $binary_string
- The binary string to convert
Warning
The parameter must be a string. Using other data types will produce unexpected results.
RETURN VALUES
The decimal value of $binary_string
EXAMPLES
Example #1
bindec(3) example
<?php
echo bindec('110011') . "
";
echo bindec('000110011') . "
";
echo bindec('111');
?>
The above example will output:
51
51
7
Example #2
bindec(3) interprets input as unsigned integers
<?php
/*
* The lesson from this example is in the output
* rather than the PHP code itself.
*/
$magnitude_lower = pow(2, (PHP_INT_SIZE * 8) - 2);
p($magnitude_lower - 1);
p($magnitude_lower, 'See the rollover? Watch it next time around...');
p(PHP_INT_MAX, 'PHP_INT_MAX');
p(~PHP_INT_MAX, 'interpreted to be one more than PHP_INT_MAX');
if (PHP_INT_SIZE == 4) {
$note = 'interpreted to be the largest unsigned integer';
} else {
$note = 'interpreted to be the largest unsigned integer
(18446744073709551615) but skewed by float precision';
}
p(-1, $note);
function p($input, $note = '') {
echo "input: $input
";
$format = '%0' . (PHP_INT_SIZE * 8) . 'b';
$bin = sprintf($format, $input);
echo "binary: $bin
";
ini_set('precision', 20); // For readability on 64 bit boxes.
$dec = bindec($bin);
echo 'bindec(): ' . $dec . "
";
if ($note) {
echo "NOTE: $note
";
}
echo "
";
}
?>
Output of the above example on 32 bit machines:
input: 1073741823
binary: 00111111111111111111111111111111
bindec(): 1073741823
input: 1073741824
binary: 01000000000000000000000000000000
bindec(): 1073741824
NOTE: See the rollover? Watch it next time around...
input: 2147483647
binary: 01111111111111111111111111111111
bindec(): 2147483647
NOTE: PHP_INT_MAX
input: -2147483648
binary: 10000000000000000000000000000000
bindec(): 2147483648
NOTE: interpreted to be one more than PHP_INT_MAX
input: -1
binary: 11111111111111111111111111111111
bindec(): 4294967295
NOTE: interpreted to be the largest unsigned integer
Output of the above example on 64 bit machines:
input: 4611686018427387903
binary: 0011111111111111111111111111111111111111111111111111111111111111
bindec(): 4611686018427387903
input: 4611686018427387904
binary: 0100000000000000000000000000000000000000000000000000000000000000
bindec(): 4611686018427387904
NOTE: See the rollover? Watch it next time around...
input: 9223372036854775807
binary: 0111111111111111111111111111111111111111111111111111111111111111
bindec(): 9223372036854775807
NOTE: PHP_INT_MAX
input: -9223372036854775808
binary: 1000000000000000000000000000000000000000000000000000000000000000
bindec(): 9223372036854775808
NOTE: interpreted to be one more than PHP_INT_MAX
input: -1
binary: 1111111111111111111111111111111111111111111111111111111111111111
bindec(): 18446744073709551616
NOTE: interpreted to be the largest unsigned integer
(18446744073709551615) but skewed by float precision
NOTES
Note
The function can convert numbers that are too large to fit into the platforms integer type, larger values are returned as float in
that case.
SEE ALSO
decbin(3), octdec(3), hexdec(3), base_convert(3).
PHP Documentation Group BINDEC(3)