Need help in find the values


 
Thread Tools Search this Thread
Top Forums Programming Need help in find the values
# 1  
Old 08-29-2015
Need help in find the values

Hi All ,

We are having a function like this . Can anyone help me in the output of DATA and the explanation of ADiv function. Thanks for your help in advance.

Code:
// token = 99.904046
  int rec = atol(token);
  Data[i]=atof(token)/ADiv[rec]; break;

token values = 99.904046



and ADiv is in .h files as

Code:
const unsigned long ADiv[] = {
		1L, 
		10L, 
		100L, 
		1000L, 
		10000L, 
		100000L, 
		1000000L, 
		10000000L, 
		100000000L, 
		1000000000L		
	};

# 2  
Old 08-29-2015
Quote:
Originally Posted by arunkumar_mca
Hi All ,

We are having a function like this . Can anyone help me in the output of DATA and the explanation of ADiv function. Thanks for your help in advance.

Code:
// token = 99.904046
  int rec = atol(token);
  Data[i]=atof(token)/ADiv[rec]; break;

token values = 99.904046



and ADiv is in .h files as

Code:
const unsigned long ADiv[] = {
		1L, 
		10L, 
		100L, 
		1000L, 
		10000L, 
		100000L, 
		1000000L, 
		10000000L, 
		100000000L, 
		1000000000L		
	};

No. You do not have a function. (Or at least you have not shown us a function.) You have shown us a declaration for an array of 10 unsigned long integer values (assuming we are looking at C or C++ code), you have shown us a comment (assuming we are looking at C++ or recent C code), you have implied that a character pointer named token has been set to point to the string "99.904046" (but you have not shown us any code that does that), you have shown us that you convert that string into a signed long integer value and assign the result to a signed integer named rec (assuming that you have correctly declared atol() or included the standard header in which it is declared), and you then assign an element of an undeclared array Data[] at an index in the array specified by another undeclared variable (i) to the division of the string mentioned earlier being converted to a floating point value (assuming that atof() has been declared correctly or that you have included the standard header in which that function is declared) by the 100th element of the 10 element array ADiv[] (which could by a division by a random value or a reference to an unallocated memory position yielding a random value or termination of your code with a memory fault).
# 3  
Old 08-29-2015
ADiv is an array containing ten elements. In order for ADiv[rec] to access the value within the boundary of the array, the return of atol(token) must be the equivalent to an index between 0 and 9, inclusive, which it will not happen with the supposedly const char *token = "99.904046";

Last edited by Aia; 08-29-2015 at 01:46 PM.. Reason: added word inclusive
# 4  
Old 08-29-2015
Here is the code. when I debugged I get token value as 99.904046 (this is the first token values we have lots of token value which we will get in getnext token function)


Code:
		int dPrec = atol(token);

		for (i=0; i < (SHORT)nTagCounts[nDim]; i++) {
			TS->GetNextToken(token);
			
			if (!strlen(token)) {
				pData[i] = 0;
			}
			else {
				if (token[0] == '*')
					// Write an N/A value
					pData[i] = fNAV;
				else {

					switch (Indicator) {
						case 'A':
						case 'I': pData[i]=atof(token)/fDiv[dPrec]; break;
						default:
							cout << "Unknown Indicator: " << Indicator << endl;
							return E_FAIL;
					}	
				}
			}
		}
        if ((*pData) != 0)
		DB->put_DataPoint(Index, pData);
		
		//The indicator
		bDone = (TS->GetNextToken(token) == S_FALSE);

	}

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find duplicate values in specific column and delete all the duplicate values

Dear folks I have a map file of around 54K lines and some of the values in the second column have the same value and I want to find them and delete all of the same values. I looked over duplicate commands but my case is not to keep one of the duplicate values. I want to remove all of the same... (4 Replies)
Discussion started by: sajmar
4 Replies

2. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

3. Shell Programming and Scripting

Find the common values

Hi, I have two files with the below values. file1 305231921 1.0 ben/Ben_Determination_Appeals 1348791394 2.0 ben/Ben_Determination_Appeals] 1305231921 1.0 ben/Cancel_Refund_Payment_JLRS 1348791394 2.0 ben/Cancel_Refund_Payment_JLRS 1305231921 ... (2 Replies)
Discussion started by: Vikram_Tanwar12
2 Replies

4. Shell Programming and Scripting

Find out values between xml tag

Find out values between xml tag ....... ABC><name></ABC><xyz>test</xyz>..here some other tag... <ABC><NUMBER></ABC><xyz>12345</xyz>.... ....... I want to take between bewtween ABC><NUMBER></ABC><xyz> to </xyz> that is 12345 (3 Replies)
Discussion started by: Jairaj
3 Replies

5. Shell Programming and Scripting

Find and replace many values

Dear Friends, I did the same question before in other thread, but I want to explain a little better my request. I am looking for a way how to find and replace a values in two files using a reference a file where are the key to replace. Basically, I want to keep a copy of the original file... (1 Reply)
Discussion started by: jiam912
1 Replies

6. UNIX for Dummies Questions & Answers

Find duplicated values in two columns out of three

hi! could u help in the following? I have the data (long list!) that looks like (three coumns white space separated): rs3094315 0.0665173 742429 rs12562034 0.0738998 758311 rs3934834 0.396449 995669 rs9442372 0.402693 1008567 rs3737728 0.406271 1011278 rs6687776 0.435429 1020428 rs9651273... (4 Replies)
Discussion started by: kush
4 Replies

7. Shell Programming and Scripting

Find distinct values

Hi, I have two files of the following format file1 chr1:345-456 chr2:123-456 chr2:455-678 chr3:456-789 chr3:444-555 file2 chr1:345-456 chr2:123-456 chr3:456-789 output (2 Replies)
Discussion started by: jacobs.smith
2 Replies

8. Shell Programming and Scripting

find values between values in two different fields

Hi, I need help to find values between two different fields based on $6 (NUM) AND $1 (CD), within the same ID. The result should show the values between the NUMs which will be extracted from within $3 and $2 in data.txt file below. data.txt ex 139 142 Sc_1000004 ID 4 CD ... (2 Replies)
Discussion started by: redse171
2 Replies
Login or Register to Ask a Question