Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Precision l...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 10 Topic 2157 of 2370
Post > Topic >>

Re: Precision lost when running gawk program from bat file

by di98mase <di98mase@[EMAIL PROTECTED] > Feb 12, 2008 at 04:43 AM

On 11 Feb, 19:37, Ed Morton <mor...@[EMAIL PROTECTED]
> wrote:
> On 2/11/2008 8:26 AM, Ed Morton wrote:
>
>
>
>
>
>
>
> > On 2/11/2008 3:40 AM, di98mase wrote:
>
> >>Hi,
>
> >>when I run a gawk program from a console window I get a different
> >>precision in my results from when I run the same program from a bat
> >>file, why is that?
>
> >>This is how I run my program in the console window:
> >>H:\semadu2\llt_tests\bl27\1.1.33.1\scripts>gawk -f..\..\..\..\scripts
> >>\llt\llt_ca
> >>lulate_transsaction_times.awk < ..\logs\test2.alc
>
> >>This gives the following output:
> >>Tr Id =A0 =A0 USN =A0 =A0 =A0 =A0Diff
> >>----------------------------------------
> >>00027037 =A00817F7DD =A0 262.614
>
> >>If I run the same program from a batch file (extract below)
> >>echo "******* Calculate all transaction times ***************"
> >>..\..\..\..\tools\gawk -f ..\..\..\..\scripts\llt
> >>\llt_calculate_transaction_times.awk <..\logs\%1 > ..\results
> >>\transaction_times.res
>
> >>This gives the following output:
> >>Tr Id =A0 =A0 USN =A0 =A0 =A0 =A0Diff
> >>----------------------------------------
> >>00027037 =A00817F7DD =A0 262
>
> >>As you can se the I loose the decimal precision? Why Is that?
> >>(note that the outputs above are extracts)
>
> > It's almost certainly related to your locale setting. Personally, I've
n=
ever had
> > much luck changing locales. The GNU awk manual
> > (http://www.gnu.org/manual/gawk/html_node/Conversion.html)
says this
sho=
uld work:
>
> > =A0 =A0 =A0$ echo 4,321 | gawk '{ print $1 + 1 }'
> > =A0 =A0 =A0-| 5
> > =A0 =A0 =A0$ echo 4,321 | LC_ALL=3Den_DK gawk '{ print $1 + 1 }'
> > =A0 =A0 =A0-| 5,321
>
> > but here's what I get (gawk 3.1.6 on cygwin):
>
> > =A0 =A0 =A0$ echo 4,321 | gawk '{ print $1 + 1 }'
> > =A0 =A0 =A05
> > =A0 =A0 =A0$ echo 4,321 | LC_ALL=3Den_DK gawk '{ print $1 + 1 }'
> > =A0 =A0 =A05
>
> > I've never pursued it as I never need it...
>
> > Regards,
>
> > =A0 =A0Ed.
>
> Well, I figured out my problem - cygwin gets its locale implementation
fro=
m
> newlib which only sup****ts C locale
(http://sourceware.org/newlib/libc.htm=
l#SEC183).
>
> For the OP, your problem may be similair, in which case converting the
","=
s to
> "."s (possibly on-the-fly) should solve your problem:
>
> $ echo 4,321 | gawk '{gsub(/,/,"."); $0 =3D $1 + 1; gsub(/\./,",")}1'
> 5,321
>
> Regards,
>
> =A0 =A0 =A0 =A0 Ed.- D=F6lj citerad text -
>
> - Visa citerad text -

Hi again,

I have searched the reference manual for more info about different
locale but without any luck? How shall I write if I want to set the
LC_ALL to swedish for instance? Also, are there more environment
variables that can be set or changed?

Rgds

/di98
 




 10 Posts in Topic:
Precision lost when running gawk program from bat file
di98mase <di98mase@[EM  2008-02-11 01:40:47 
Re: Precision lost when running gawk program from bat file
Ed Morton <morton@[EMA  2008-02-11 08:26:47 
Re: Precision lost when running gawk program from bat file
Ed Morton <morton@[EMA  2008-02-11 12:37:57 
Re: Precision lost when running gawk program from bat file
Toby Darling <anotherc  2008-02-11 07:00:11 
Re: Precision lost when running gawk program from bat file
di98mase <di98mase@[EM  2008-02-11 08:08:08 
Re: Precision lost when running gawk program from bat file
Galen <gltackett@[EMAI  2008-02-11 09:29:25 
Re: Precision lost when running gawk program from bat file
Toby Darling <anotherc  2008-02-11 10:01:45 
Re: Precision lost when running gawk program from bat file
di98mase <di98mase@[EM  2008-02-12 04:43:40 
Re: Precision lost when running gawk program from bat file
Ed Morton <morton@[EMA  2008-02-12 07:32:07 
Re: Precision lost when running gawk program from bat file
di98mase <di98mase@[EM  2008-02-12 06:28:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 17:38:47 CDT 2008.