Sponsored Content
Top Forums Shell Programming and Scripting Replace floating-point by integer in awk Post 302163176 by smadonald1 on Thursday 31st of January 2008 06:35:02 AM
Old 01-31-2008
Thanks vgersh99 !!!

The S[i] = int($3) command worked a charm!

the output is perfect...

36
-572.44987938
Pd -0.212918 0.004511 0.022713
P -0.152320 -2.360683 0.037839
P -0.157447 2.366475 -0.066462
C -2.300322 -0.042021 0.060348
H -2.660893 -0.611970 -0.808329
H -2.613078 -0.538682 0.988993
H -2.739315 0.960898 0.028249
O 2.117646 -0.659949 -0.986743
H 2.366548 -0.108745 -1.747134
H 2.271505 -0.009514 0.035132
O 2.092218 0.645113 1.053500
H 2.310793 0.094472 1.823721
C 1.370822 -3.099086 0.827188
H 1.386621 -2.849606 1.898103
H 2.242302 -2.652521 0.329789
H 1.377317 -4.194074 0.706847
C -0.117670 -3.069906 -1.689405
H 0.749056 -2.628859 -2.199087
H -0.033101 -4.168041 -1.668271
H -1.037221 -2.783124 -2.220210
C -1.540751 -3.321685 0.853492
H -1.384633 -4.405730 0.739767
H -2.503214 -3.046919 0.398931
H -1.577146 -3.072302 1.924305
C -0.226934 3.158669 1.623556
H 0.602118 2.742269 2.211242
H -0.133838 4.254254 1.555691
H -1.179894 2.900727 2.108129
C -1.476324 3.302192 -1.019132
H -2.472726 3.070857 -0.616182
H -1.306484 4.388200 -0.953136
H -1.448164 2.993615 -2.074466
C 1.418810 3.057762 -0.791369
H 2.253202 2.621749 -0.225615
H 1.430697 4.156742 -0.716978
H 1.494764 2.762780 -1.848113
36
-572.44987938
Pd -0.212918 0.004511 0.022713
P -0.152320 -2.360683 0.037839
P -0.157447 2.366475 -0.066462
C -2.300322 -0.042021 0.060348
H -2.660893 -0.611970 -0.808329
H -2.613078 -0.538682 0.988993
H -2.739315 0.960898 0.028249
O 2.117646 -0.659949 -0.986743
H 2.366548 -0.108745 -1.747134
H 2.271505 -0.009514 0.035132
O 2.092218 0.645113 1.053500
H 2.310793 0.094472 1.823721
C 1.370822 -3.099086 0.827188
H 1.386621 -2.849606 1.898103
H 2.242302 -2.652521 0.329789
H 1.377317 -4.194074 0.706847
C -0.117670 -3.069906 -1.689405
H 0.749056 -2.628859 -2.199087
H -0.033101 -4.168041 -1.668271
H -1.037221 -2.783124 -2.220210
C -1.540751 -3.321685 0.853492
H -1.384633 -4.405730 0.739767
H -2.503214 -3.046919 0.398931
H -1.577146 -3.072302 1.924305
C -0.226934 3.158669 1.623556
H 0.602118 2.742269 2.211242
H -0.133838 4.254254 1.555691
H -1.179894 2.900727 2.108129
C -1.476324 3.302192 -1.019132
H -2.472726 3.070857 -0.616182
H -1.306484 4.388200 -0.953136
H -1.448164 2.993615 -2.074466
C 1.418810 3.057762 -0.791369
H 2.253202 2.621749 -0.225615
H 1.430697 4.156742 -0.716978
H 1.494764 2.762780 -1.848113

etc...

Thanks again
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem with floating point numbers in awk

hi all, i have the following problem using awk in a script i want to read the values from a column with real numbers and calculate the mean.the problem is that when i use a statement such as this num = $4 i cant find a way to convert the variable from string to floating point to perform... (7 Replies)
Discussion started by: kanagias
7 Replies

2. Programming

Floating point error in C

Hi, see the simple code below double i; i=8080.9940; printf(" val :%.30f\n",i); output i m getting is val :8080.993999999999700000000000000 when i m expecting val :8080.9940 what happens?how can i avoid it? thanks... (2 Replies)
Discussion started by: Hara
2 Replies

3. Linux

Floating Point Exception

Hi, I am compiling "HelloWorld" C progam on 32-bit CentOS and i want to execute it on 64-bit CentOS architecture. For that i copied the a.out file from 32-bit to 64-bit machine, but while executing a.out file on 64bit machine I am getting "Floating point exception error". But we can run... (3 Replies)
Discussion started by: Mandar123
3 Replies

4. Programming

Floating point Emulator

what is floating point emulator(FPE)? where and why it is used? (1 Reply)
Discussion started by: pgmfourms
1 Replies

5. UNIX for Dummies Questions & Answers

Check if input is an integer or a floating point?

Hiii I actually intent to check the integer or floating point number input by user i.e. 23, 100, 55.25, 12.50 ..etc. However, when someone input strings or alpha character, my program has to show invalid input.!! Is there any Unix shell script syntax can help me to check ? Thanking you (2 Replies)
Discussion started by: krishnampkkm
2 Replies

6. Shell Programming and Scripting

Floating point to integer in variable length lines

Hi ! I'm looking for a way to transform certain floating point numbers in a one-line, variable length file to integers. I can do this in a crude way with sed : sed -e 's/0\.\(\):/\1:/g' -e 's/0\.0\(\):/\1:/g' -e 's/1\.000:/100:/g' myfile ... but this doesn't handle the rounding correctly. ... (3 Replies)
Discussion started by: jossojjos
3 Replies

7. Shell Programming and Scripting

awk, floating point and rounding

I had a person bring an interesting problem to me that appears to involve some sort of rounding inside awk. I've verified this with awk and nawk on Solaris as well as with gawk 3.1.5 on a Linux box. The original code fragment he brought me was thus: for (index=0; index < 1; index=index+.1) ... (4 Replies)
Discussion started by: mmyer2
4 Replies

8. Programming

Floating Point

Anyone help me i cant found the error of floating point if needed, i added the code complete #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> typedef struct { int hh; int mm; int ss; char nom; int punt; }cancion; typedef struct... (9 Replies)
Discussion started by: Slasho
9 Replies

9. UNIX Desktop Questions & Answers

awk a integer and replace it minus X

hey, i have a list of devices that looks like so: VolumeTask(DeviceName(DeviceName(DeviceNameInfo(MultiPathType_UID(Option<GUDeviceID>(GUDeviceID(ulonglong(358271365120608989UL))),Option<ulong>())))),2098560),... (5 Replies)
Discussion started by: boaz733
5 Replies

10. Shell Programming and Scripting

Comparing floating number and replace the smaller one with awk?

Hi guys, I tried to write a script for replacing some number in a bunch of files. However, I failed because my limited bash scripting knowledge. Here I will explain the expected function: I have many data files need to be processed. Here shows one part of a file as an example: a list with... (7 Replies)
Discussion started by: liuzhencc
7 Replies
NBPERF(1)						    BSD General Commands Manual 						 NBPERF(1)

NAME
nbperf -- compute a perfect hash function SYNOPSIS
nbperf [-ps] [-a algorithm] [-c utilisation] [-h hash] [-i iterations] [-m map-file] [-n name] [-o output] [input] DESCRIPTION
nbperf reads a number of keys one per line from standard input or input. It computes a minimal perfect hash function and writes it to stdout or output. The default algorithm is "chm". The -m argument instructs nbperf to write the resulting key mapping to map-file. Each line gives the result of the hash function for the corresponding input key. The parameter utilisation determines the space efficiency. Supported arguments for -a: chm This results in an order preserving minimal perfect hash function. The utilisation must be at least 2, the default. The number of iterations needed grows if the utilisation is very near to 2. chm3 Similar to chm. The resulting hash function needs three instead of two table lookups when compared to chm. The utilisation must be at least 1.24, the default. This makes the output for chm3 noticable smaller than the output for chm. bpz This results in a non-order preserving minimal perfect hash function. Output size is approximately 2.79 bit per key for the default value of utilisation, 1.24. This is also the smallest supported value. Supported arguments for -h: mi_vector_hash Platform-independent version of Jenkins parallel hash. See mi_vector_hash(3). The number of iterations can be limited with -i. nbperf outputs a function matching uint32_t hash(const void * restrict, size_t) to stdout. The function expects the key length as second argument, for strings not including the terminating NUL. It is the responsibility of the call- er to pass in only valid keys or compare the resulting index to the key. The function name can be changed using -n name. If the -s flag is specified, it will be static. After each failing iteration, a dot is written to stderr. nbperf checks for duplicate keys on the first iteration that passed basic hash distribution tests. In that case, an error message is printed and the program terminates. If the -p flag is specified, the hash function is seeded in a stable way. This may take longer than the normal random seed, but ensures that the output is the same for repeated invocations as long as the input is constant. EXIT STATUS
The nbperf utility exits 0 on success, and >0 if an error occurs. SEE ALSO
mi_vector_hash(3) AUTHORS
Jorg Sonnenberger BSD
September 25, 2012 BSD
All times are GMT -4. The time now is 09:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy