Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

WWWXXXDOCO, nu vot, WWWXXXAPC, dhcpd lease file "binding state", WWWXXXDOCO, how to setup procmail to process html2text, how to setup procmail html2text, WWWXXXAPC., XXXCNZZZ, ss4000 recovery array

Links

XODOX
Impressum

#1: weird output with typeset -F

Posted on 2005-02-15 19:56:10 by bfay

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

Report this message

#2: Re: weird output with typeset -F

Posted on 2005-02-15 20:40:06 by Chris Barts

bfay@deepcosmos.ca wrote:
> Does someone know why I have the weird output in the following piece of
> code?
>
> typeset -F5 X=123.456
> print $X
> 5#443

Which shell are you using? Under zsh 4.0.7, I get:

typeset -F5 X=123.456
print $X
123.45600

Report this message

#3: Re: weird output with typeset -F

Posted on 2005-02-15 20:59:38 by bfay

I use ksh on AIX.

Report this message

#4: Re: weird output with typeset -F

Posted on 2005-02-15 22:48:23 by brian_hiles

bfay@deepcosmos.ca wrote:
> Does someone know why I have the weird output in the following piece
of
> code?
> typeset -F5 X=123.456
> print $X
> 5#443

I would have said that ksh on AIX is _apparently_ ksh version 1993
or newer, which is the only distribution kornshell which implements
the -F (floating point) option to the builtin command typeset;
however, the "5" parameter option is parsed in the context of the
-i option, wherein it defines the radix of the display, not the
formatted width of the display, as it should.

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

Report this message

#5: Re: weird output with typeset -F

Posted on 2005-02-15 22:53:00 by Dan Mercer

<bfay@deepcosmos.ca> wrote in message news:1108497578.417493.293240@g14g2000cwa.googlegroups.com.. .
: 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

Report this message

#6: Re: weird output with typeset -F

Posted on 2005-02-16 01:16:35 by frank

If you're on Aix 5 use /usr/bin/ksh93.

<bfay@deepcosmos.ca> wrote in message
news:1108493770.479162.72720@l41g2000cwc.googlegroups.com...
> 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
>

Report this message

#7: Re: weird output with typeset -F

Posted on 2005-02-17 19:32:25 by bfay

"Frank" <chiavoni@tcnj.edu> wrote in message news:<ZhwQd.92$Jz5.90@fe12.lga>...
> If you're on Aix 5 use /usr/bin/ksh93.
>
> <bfay@deepcosmos.ca> wrote in message
> news:1108493770.479162.72720@l41g2000cwc.googlegroups.com...
> > 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
> >


Gentlemen,

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

Report this message