Can someone explain to me please why the scale=3 fails to give me an answer to 3 decimal places in the first example of calling bc below but succeeds in the second?
I know I can use a printf modifier to get the answer to 3 decimal places but I'd like to understand what's going on with bc.
scale is implementation dependent, meaning: it affects "some" operations. Algorithms also look at length - the number of significant digits in the operands.
That is why 10 /3 got scaled and the other one did not.
bc was/is a front end for another program, dc.
This was true in earlier versions of HPUX and BSD. The source (dc and bc @Bell Labs) worked that way.
Although bc is "POSIX" there are NO standards about how to implement scale or ibase, or obase; just slightly what bc -l entails, and not even what functions or values are declared. The only positive standard is bc -l sets scale to default 20.
Methyl - dividing by 1 also results in the answer being given to 3 decimal places with my version of bc.
Am I correct in thinking that for portability people just have to assume that bc's scale (to reduce precision) does not actually work, so if a result needs to be given at a certain (reduced) precision they have to use a printf modifier or such like?
Jim - when you say bc is "POSIX" does that mean there is a list of programs that are guaranteed to be on POSIX compliant OSs? If so where would I find the list? I just did a search and couldn't find anything. Or are the "" around POSIX meant to say - strictly unofficial? Is there an unofficial list?
[...]
Jim - when you say bc is "POSIX" does that mean there is a list of programs that are guaranteed to be on POSIX compliant OSs? If so where would I find the list? I just did a search and couldn't find anything. Or are the "" around POSIX meant to say - strictly unofficial? Is there an unofficial list?
Would you guys say that all OS's which fall in the mostly POSIX-compliant category (Eg. Linux, OpenBSD, etc.) have all of those utilities installed? So it is not necessary when writing a bash script to have code that checks if bc, sed, tr, grep, and so on are installed on the system?
Would you guys say that all OS's which fall in the mostly POSIX-compliant category (Eg. Linux, OpenBSD, etc.)
have all of those utilities installed? So it is not necessary when writing a bash script to have code that checks if bc,
sed, tr, grep, and so on are installed on the system?
[...]
Yes, unless the system has been modified ...
Be aware though that most operating systems usually provide more than one implementation of those utilities
(for example POSIX grep vs. standard Solaris grep).
So in order to access the POSIX versions of the above mentioned programs
on some systems (Solaris comes to mind), you'll need to set your PATH:
or (if you're already in a POSIX compliant shell):
Hi 2 all,
i have had AIX 7.2
:/# /usr/IBMAHS/bin/apachectl -v
Server version: Apache/2.4.12 (Unix)
Server built: May 25 2015 04:58:27
:/#:/# /usr/IBMAHS/bin/apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_worker_module (static)
... (3 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
both ksh/bash support this 2 special variables, Is there any document for reference?
1) "-" is $OLDPWD
2) "$_" is last argument of previous command. (4 Replies)
hi,
I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses...
Here is the configuration of my system:
* an IBM P550 machine,
* an AIX 5.3 running on it and
* an oracle database, already installed on it.
The problem (or... (1 Reply)
hi,
I have
* an IBM P550 machine,
* an AIX 5.3 running on it and
* an oracle database, already installed on it.
The problem (or question of my own) is:
Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)