Sponsored Content
Top Forums Shell Programming and Scripting Floating point to integer in variable length lines Post 302413304 by Franklin52 on Thursday 15th of April 2010 07:38:52 AM
Old 04-15-2010
Not sure how complex the other lines are but with the given example this should work:
Code:
awk -F")" '{
  for(i=2;i<NF;i++){
    f=s=$i
    sub(":.*","",f)
    sub(".*:","",s)
    f=sprintf("%d",f+=f<0?-0.5:0.5)
    sub($i,f ":" s)
  }
}1' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

floating point variable in UNIX script

HI all, Can someone help me how to use or assign a floating point value in a variable in a unix script. I dont know how to use it. for example, I am to assign a variable VAR1 a value of 2.34 and evaluate if a certain vaue is greater or less than to it. That is, if var1 > 2.13 will do... (7 Replies)
Discussion started by: darry
7 Replies

2. Shell Programming and Scripting

floating point shell variable

I have a two files >cat file1 jjjjj 10.345 6.673 ppp 9.000 5.883 >cat file2 mmm 80 10 jjjjj 10.305 6.873 ppp 9.000 5.883 I am reading file 1 line by line , and look for the string jjjj and then read the line in file 2 with jjjj I want to get the... (5 Replies)
Discussion started by: jojan
5 Replies

3. Shell Programming and Scripting

Replace floating-point by integer in awk

Hi, I am trying to write a script to extract multiple sets of data from a chemistry output file. The problem section is in the following format... Geometry "geometry" -> "geometry" 1 Pd 46.0000 -0.19290971 0.00535260 0.02297606 2 P ... (7 Replies)
Discussion started by: smadonald1
7 Replies

4. Shell Programming and Scripting

Rounding off the value of Floating point value

Hello, i have some variables say: x=1.4 y=3.7 I wish to round off these values to : x = 2 (after rounding off) y = 4 (after rounding off) I am stuck. Please help. (7 Replies)
Discussion started by: damansingh
7 Replies

5. Shell Programming and Scripting

floating point numbers in if

# if > then > echo "1" > else > echo "2" > fi -bash: How can i compare floating point numbers inside statement? (15 Replies)
Discussion started by: proactiveaditya
15 Replies

6. Shell Programming and Scripting

Arithmetic in floating point

is it not possible to simply di aritmetic without using bc or awk i have tried folllowing operatrions but they support only integer types plz suggest me code for floating using values stored in the variables.the ans i get is integer and if i input floating values i get error numeric constant... (6 Replies)
Discussion started by: sumit the cool
6 Replies

7. 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

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. Shell Programming and Scripting

Add leading zeros in floating point variable

I need to add leading zeros in a floating point numbers. The length of the number should be 13 including decimal. The input number is changing so number of leading zeros is not fix. For example input output 216.000 000000216.000 1345.000 000001345.000 22345.500 ... (4 Replies)
Discussion started by: reeta_shri
4 Replies

10. Shell Programming and Scripting

IF statement on floating point variable in scientific format

Hi all, I'm struggling :wall: to make a an if statement on two variables in scientific format. e.g. a=1.23e+01 b=3.21e+02 I know that it can be done with bc if the variable are not in scientific format. But what to do in this case??? Thank you, (3 Replies)
Discussion started by: f_o_555
3 Replies
cpow(3M)						  Mathematical Library Functions						  cpow(3M)

NAME
cpow, cpowf, cpowl - complex power functions SYNOPSIS
cc [ flag... ] file... -lm [ library... ] #include <complex.h> double complex cpow(double complex x, double complex y); float complex cpowf(float complex x, float complex y); long double complex cpowl(long double complex x, long double complex y); DESCRIPTION
These functions compute the complex power function x^y, with a branch cut for the first parameter along the negative real axis. RETURN VALUES
These functions return the complex power function value. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
cabs(3M), complex.h(3HEAD), csqrt(3M), attributes(5), standards(5) SunOS 5.10 1 Sep 2002 cpow(3M)
All times are GMT -4. The time now is 12:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy