Does someone know why I have the weird output in the following piece of
code?
typeset -F5 X=123.456
print $X
5#443
Thanks,
Bernard
typeset -F5 X=123.456
print $X
5#443
Thanks,
Bernard
> typeset -F5 X=123.456
> print $X
> 5#443
typeset -F5 X=123.456
print $X
123.45600
I presume you understand that what "5#443" is telling you is
that 443 is base 5 for 123 [base 10].
Although I cannot verify this, in my experience, AIX OS and apps
are inappropriately "munged" as IBM's source license will allow,
as well as exhibiting "hybrid" characteristics between canonical
distribution versions of apps and tools. This is certainly true
of my experiences with the AIX port of sed(1), which was working
just fine until some IBM programmer was told to remove all
identifying information in sed(1) diagnostic output!
As AIX ksh is truncating the result, it is behaving as if IBM had
added in their ksh88 the compatibility option -F as an "alias" to
option -i. The exhibited behavior is how many (but not all) ksh88
ports work: they accept floating point notation, but do implicit
integral truncation.
A BIG :( for AIX!
I would use the below as a workaround. This solution has the merit
of at least being compatible to non-broken versions of ksh93!
# AIX: use base 10 as radix (default)
# UNIX: 10 char width (default)
typeset -F10 X=123.456
print -f %5d $X
But this is not going to help you if you genuinely need to do
floating point operations in ksh93. In that case, your two alternatives
are to either use dc(1)/bc(1), or download a _real_ ksh93 port for AIX
from:
http://www.research.att.com/sw/download/
=Brian
: I use ksh on AIX.
:
Isn't that ksh88? Floating point is a ksh93 feature (which should be
available, at least as dtksh). What is the result of
$ print ${.sh.version}
?
Dan Mercer
Quote:> Does someone know why I have the weird output in the following piece of
> code?
> typeset -F5 X=123.456
> print $X
> 5#443
> Thanks,
> Bernard
> > Does someone know why I have the weird output in the following piece of
> > code?
> > typeset -F5 X=123.456
> > print $X
> > 5#443
> > Thanks,
> > Bernard
My version of ksh is 88 and the beast where I need the floating point
is AIX 4.3. Also, on the beast with AIX 5.2, the floating point on
ksh93 works just fine.
The option -f in the command `print -f %d5 $X` does not work.
I don't want to install ksh93 on my 4.3 box therefore I'll try to
swith to perl.
thanks to everyone,
Bernard
1. typeset -f gives funny output when executed from Korn shell script
I just discovered a funny behaviour of the typeset -f command when
executed in a shell script.
Assume function a is defined in your ENV file (.kshrc)
---------- begin .kshrc
function a {
: # this is function a
---------- end .kshrc
and file foo contains the following lines
---------- begin foo
function b {
: # this is function b
typeset -f
---------- end foo
Sourcing foo gives the following output
---------- begin output of ". foo"
function a
{
: # this is function a
function b
{
: # this is function b
---------- end output of ". foo"
while executing foo gives
---------- begin output of "foo"
function a
{
<command unknown>
function b
---------- end output of "foo"
and, as you might (not) expect :
---------- begin output of "ksh foo"
function a
function b
---------- end output of "ksh foo"
Is this typycal to my implementation of the Korn shell (HP 9000/400,
HP-UX 8.0) or is it a
- ksh bug,
- ksh undocumented feature,
- ksh documented feature well hidden in TFM?
Marc.
--
Marc PHILIPS Eurocontrol - Central Flow Management Unit
Tel: +32 2 729 33 09 B-1040 BRUXELLES
Fax: +32 2 729 32 16 Belgium
2. PnP sound in the new pre 2.2 kernel
3. Weird Ping, weird FTP, weird Telnet... HELP!!!
5. Weird, weird, weird issue ....
9. Weird Bug - Output redirection causes coredump
13. Fwd: Re: [BUG][2.5.64bk4] Weird problem with 2 PCs - OUTPUT OF PANIC