469,643 Members | 1,486 Online

# Regarding Time conversion, secondly number comparison

Hi,
I am working on awk programming which is similar to C programming and
have got a doubt about time function returning a float value.
Ex: 01:01:30 should return 61.5 when i have tried my way i am not able
to get the seconds value (30/60=0.5)
So can anyone give me ideas, throught which i can do similar coding in
AWK programming.

Secondly i am comparing two number.
Ex: 91402777777 is the dialled number and the area code is 91 (Which
has got calculation needed to be done upon comparing.
When i was doing the string comparison
it was matching number 9 and putting the local rate calculations, but
the number being international.
So this is also being carried out in AWK programming.
can u give me suggestions as how number comparison and time conversion
can be carried out.
i am trying all different option, your suggestion might be the one i am
looking for but not able to get it.....

Nov 15 '05 #1
3 1690
Chandu wrote:
Hi,
I am working on awk programming which is similar to C programming and
have got a doubt about time function returning a float value.
Ex: 01:01:30 should return 61.5 when i have tried my way i am not able
to get the seconds value (30/60=0.5)
So can anyone give me ideas, throught which i can do similar coding in
AWK programming.
Have you considered integer division vs. floating point division?

Secondly i am comparing two number.
Ex: 91402777777 is the dialled number and the area code is 91 (Which
has got calculation needed to be done upon comparing.
When i was doing the string comparison
it was matching number 9 and putting the local rate calculations, but
the number being international.
I have not the least clue as to what you are doing, so I cannot

So this is also being carried out in AWK programming.
can u give me suggestions as how number comparison and time conversion
can be carried out.
i am trying all different option, your suggestion might be the one i am
looking for but not able to get it.....

Why don't you ask this in an AWK newsgroup? Hint: There is comp.lang.awk
but any groups containing "lang.awk" may be helpful. Check their charter
and FAQ first and have a look at past threads before posting.

Also consider demonstrating your problems with a _minimal_ _running_
example AWK script. Your description may be inaccurate in a vital spot.
It was not helpful for me.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #2
"Chandu" <ph***************@gmail.com> wrote in message
Hi,
I am working on awk programming which is similar to C programming and
have got a doubt about time function returning a float value.
Ex: 01:01:30 should return 61.5 when i have tried my way i am not able
to get the seconds value (30/60=0.5)
So can anyone give me ideas, throught which i can do similar coding in
AWK programming.
AWK != C, hence is OT in this group.

A few hints:
It's best to use integer time for it has no rounding problems inherent in
floating point. See for example the single unix specification (available for
free on the net) on how amount of seconds since unix epoch can be converted
to year,month,day (+day of week),hour,minute,second and backwards. There's
somewhere an example.
Secondly i am comparing two number.
Ex: 91402777777 is the dialled number and the area code is 91 (Which
has got calculation needed to be done upon comparing.
When i was doing the string comparison
it was matching number 9 and putting the local rate calculations, but
the number being international.

I'm not sure I get your problem. Is the number stored in a string or in
integer variable?
Either you need bigger integer type or proper comparison of number strings.

Alex
Nov 15 '05 #3
Chandu wrote on 19/09/05 :
I am working on awk programming which is similar to C programming and
Note that we are strictly speaking C here. Awk is a foreign language we
don't speak.
have got a doubt about time function returning a float value.
Ex: 01:01:30 should return 61.5 when i have tried my way i am not able
to get the seconds value (30/60=0.5)
Are we supposed to read your mind to know what is non working the
C-code you have written ?
Secondly i am comparing two number.
Ex: 91402777777 is the dialled number and the area code is 91 (Which
has got calculation needed to be done upon comparing.
When i was doing the string comparison
it was matching number 9 and putting the local rate calculations, but
the number being international.
So this is also being carried out in AWK programming.
can u give me suggestions as how number comparison and time conversion
can be carried out.
i am trying all different option, your suggestion might be the one i am
looking for but not able to get it.....

I got the feeling that you should better use a string process than a
numerical one...

Once again, awk is not spoken right there. C-only.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Mal nommer les choses c'est ajouter du malheur au
monde." -- Albert Camus.
Nov 15 '05 #4

### This discussion thread is closed

Replies have been disabled for this discussion.