Sponsored Content
Top Forums Shell Programming and Scripting problem in awk int() function Post 302272963 by qa.bingo on Friday 2nd of January 2009 03:26:38 AM
Old 01-02-2009
problem in awk int() function

awk -vwgt=$vWeight -vfac=$vFactor '
BEGIN {
printf("wgt:" wgt "\n");
printf("factor:" fac "\n");
total = sprintf("%.0f", wgt * fac);
total2 = sprintf("%.0f", int(wgt * fac));
printf("total:" total "\n");
printf("total2:" total2 "\n");
}
'
if
vWeight=326.4
vFactor=100

the result would be:
total:32640
total2:32639

Could anyone know how is 32639 calucated?

thanks!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

2. Shell Programming and Scripting

awk , function call problem

#!/bin/bash awk ' function ad(t,r){ return (t+r); } BEGIN{ print ad(5,3); } { print ad(5,3); } ' Doesn't print anything for the last print ad(5,3); (6 Replies)
Discussion started by: cola
6 Replies

3. Shell Programming and Scripting

Awk problem: How to express the single quote(') by using awk print function

Actually I got a list of file end with *.txt I want to use the same command apply to all the *.txt Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics. For example: I got the file below: file1.txt file2.txt file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies

4. UNIX for Advanced & Expert Users

AWK sub function curious problem under bash

I need to detect the number of pages in a print job when it is available so I can warn users when they try to print a report much larger than they expected. Sometimes they are trying to print 1000 page reports when they thought they were getting a 10 page report. Under linux I am scanning the... (5 Replies)
Discussion started by: Max Rebo
5 Replies

5. Shell Programming and Scripting

AWK Problem in recursive function

Hi, I have a file like this SPF_HC00001|iCalcular_Monto_Minimo|--->|SPF_HC00028|pstcObtener_Monto_Minimo SPF_HC00004|iCalcular_Incrementos|--->|SPF_HC00032|pstcObtener_Num_Incrementos SPF_HC00005|iCalcular_Articulo_167_Reformado|--->|SPF_HC00031|pstcObtener_Por_CB_Inc... (2 Replies)
Discussion started by: kcoder24
2 Replies

6. Shell Programming and Scripting

Awk issue using int function

Hi, I am having issue with awk command . This command is running in the command prompt but inside a shell script. awk -F'| ' 'int($1)==$1 && int($3) ==$3' int_check.txt $cat int_check.txt 123|abc|123x 234|def|345 When i run it inside a shell script i am getting the error "bailing... (5 Replies)
Discussion started by: ashwin3086
5 Replies

7. Shell Programming and Scripting

Problem using function in awk

I created two functions that output two random variables. I want to output them in the output file. But it does not seem to work. # Function rgaussian1(r1, r2) # Gaussian random number generator function rgaussian1(r1, r2) { pi = 3.142 v1 = sqrt( -2 * log(rand()) ) v2... (18 Replies)
Discussion started by: kristinu
18 Replies

8. Shell Programming and Scripting

Perl int function solved

Hello, I have the below perl function int to return the integer value from the expression but it is not. I am not sure if something misses out here. Any help on this? Thanks in advance. # Code sample Start my $size = int (`1134 sample_text_here`); print "$size \n"; # Code end ----------... (0 Replies)
Discussion started by: nmattam
0 Replies

9. Programming

Handle int listen(int sockfd, int backlog) in TCP

Hi, from the manual listen(2): listen for connections on socket - Linux man page It has a parameter called backlog and it limits the maximum length of queue of pending list. If I set backlog to 128, is it means no more than 128 packets can be handled by server? If I have three... (3 Replies)
Discussion started by: sehang
3 Replies

10. Programming

Function main returning int?

H friends, As we know, a function returns a value and that value is saved somwhere. like int Sum( int x, int y ) { return x + y; } Total = Sum( 10, 20 ); The value 30 is saved in variable Total. Now the question is, what int value does the function main return, and where is it... (5 Replies)
Discussion started by: gabam
5 Replies
PAPI_get_overflow_event_index(3)				       PAPI					  PAPI_get_overflow_event_index(3)

NAME
PAPI_get_overflow_event_index - converts an overflow vector into an array of indexes to overflowing events SYNOPSIS
Detailed Description @param EventSet an integer handle to a PAPI event set as created by PAPI_create_eventset @param overflow_vector a vector with bits set for each counter that overflowed. This vector is passed by the system to the overflow handler routine. @param *array an array of indexes for events in EventSet. No more than *number indexes will be stored into the array. @param *number On input the variable determines the size of the array. On output the variable contains the number of indexes in the array. @retval PAPI_EINVAL One or more of the arguments is invalid. This could occur if the overflow_vector is empty (zero), if the array or number pointers are NULL, if the value of number is less than one, or if the EventSet is empty. @retval PAPI_ENOEVST The EventSet specified does not exist. @par Examples void handler(int EventSet, void *address, long_long overflow_vector, void *context){ int Events[4], number, i; int total = 0, retval; printf("Overflow #%d Handler(%d) Overflow at %p! vector=0x%llx0, total, EventSet, address, overflow_vector); total++; number = 4; retval = PAPI_get_overflow_event_index(EventSet, overflow_vector, Events, &number); if(retval == PAPI_OK) for(i=0; i<number; i++) printf("Event index[%d] = %d", i, Events[i]);} * @see PAPI_overflow Author Generated automatically by Doxygen for PAPI from the source code. Version 5.2.0.0 Tue Jun 17 2014 PAPI_get_overflow_event_index(3)
All times are GMT -4. The time now is 08:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy