Originally posted by Heedunk ... if the number is 432, it will give hundred as the number of decimal places.
Heedunk, I'm not sure I follow.. in math, there is no "number of decimal places", unless you're talking about two numbers after the decimal, or three numbers before the decimal. I assume you want to display what the largest column is..? As in ten, hundred, or a thousand?
Maybe someone has a better solution, but I think you'll need a case statement... in ksh:
Good Day
I mistakely renamed the dld.sl file in the /usr/lib directory. When i try to ls/ftp into the box i get this error :eek:
crt0: ERROR couldn't open /usr/lib/dld.sl errno:000000002
I have tried to rename it back from the renamed file to the original file name, but it gives me the... (2 Replies)
When trying to copy a file in Solaris 8 it doesnt copy file or give a error. This worked 100% until the 29th. I've checked the rights and everything seems fine:
drwxrwxrwx 2 bmuser bmgroup 11776 Jan 3 10:32 spool
This is the file I want to copy:
-rwxrwxrwx 1 bmuser bmgroup ... (26 Replies)
Hii All,
I am using openldap v2.3 on redhat El-4. When i run ldapsearch it returns all the entries. The command runs successfully. But when I run the ldapsearch with following filter option it doesnt work and immediately returns to the shell.
ldapsearch uidNumber>=2000
I've started slapd... (0 Replies)
Hi,
I have a script which does a tar and sends it to another server as backup.
Script is as below
# Locations to be backed up. Seperate by space
BACKUP_LOCATIONS=/repos/subversion
BACKUP_BASE_FOLDER=/bakpool
BACKUP_FILE_NAME_ROOT=svn-backup
START_TIME_DISP=`date`
START_TIME=`date... (11 Replies)
It just does the break...even though the files are not the same...
# Compare extracts
#==========================================
count=0
while (( count < 5 ))
do
(( count+=1 ))
echo "Try $count"
file1=$(ls -l /tmp/psjava.xml|... (5 Replies)
this is my file I have written.
// My first C++ program
#include <iostream>
int main()
{
std::cout << "Hi there!" << std::endl";
std::cout << "This is my first C++ program" << std::endl";
return(0);
}
This is the error I get, why?
$ g++ first.cpp
ksh: g++: not found (1 Reply)
Hi Guys,
I have a strange problem.( AIX 6.1) "vi" is not working at all..Whenever i #vi <anythin> ,, it returns the prompt back. Any clues folks?? (14 Replies)
I am trying to print out two fields in a file using awk. So, I have got
awk -F '\t' 'NF = 2 {print $1 $2 "]"}' two.txt
in a script called what.awk
When i run this version like this - ./what.awk then it runs however I want to run the program like this
awk -f what.awk two.txt.
When I... (8 Replies)
Hi All,
i created the below script to move file with xml extension from one directory to another,but the mv command is not working inside the shell script,
#!/us/bin/ksh
filepath="/apps/extract"
filename="*.xml"
foldername=2191POB000_$(date +%Y%m%d%H%M%S)
mkdir -p "$filepath/$foldername"... (3 Replies)
Discussion started by: Radhas
3 Replies
LEARN ABOUT PHP
bindec
BINDEC(3) 1 BINDEC(3)bindec - Binary to decimalSYNOPSIS
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)