vector.com|Contact
Search tips

apple banana
Find rows that contain at least one of the two words.

+apple +juice
Find rows that contain both words.

+apple macintosh
Find rows that contain the word 'apple', but rank rows higher if they also contain 'macintosh'.

+apple -macintosh
Find rows that contain the word 'apple' but not 'macintosh'.

+apple ~macintosh
Find rows that contain the word 'apple', but if the row also contains the word 'macintosh', rate it lower than if row does not. This is "softer" than a search for '+apple -macintosh', for which the presence of 'macintosh' causes the row not to be returned at all.

+apple +(>turnover >strudel)
Find rows that contain the words 'apple' and 'turnover', or 'apple' and 'strudel' (in any order), but rank 'apple turnover' higher than 'apple strudel'.

apple*
Find rows that contain words such as 'apple', 'apples', 'applesauce', or 'applet'.

"some words"
Find rows that contain the exact phrase 'some words' (for example, rows that contain 'some words of wisdom' but not "some noise words").

By continuing to use this site you agree to the use of cookies. For more information and to find out how to change this click here. Accept Cookies
Please enable cookies in your browser for this website.
Search:
Advanced search

Conversion of Values in E Notation to Decimal Numbers in CAPL

Last updated: 2020-02-06
Question:

How to convert string number in E notation to number in CAPL.

Background:

In CAPL large numbers may be displayed in E notation in logs, trace and measurement values. Sometimes it may be required to convert these values read as string to numbers for programming purpose. The CAPL functions atoi64(), atodbl() and atoll() cannot convert a string number in E notation to number. To compensate for this, the function below can be used.

Answer:

Please see the CAPL code below:

 on key 's'
{
  
char numberString[100] = "2.25179981368525E+015"; //string number in E notation  
char numberStringCorrected[100]; //
  long pos, decimalPos;
  int i, exponentNumber;
  int counter = 0;
  char exponentString[510];
  int64 numberNumber;
  
  pos = mbstrstr(numberString,"E+");
  decimalPos = mbstrstr(numberString,".");
  write("Position is %d", pos);
  write("Total No of Characters is %d", strlen(numberString));
  write("No of Characters to copy is %d", strlen(numberString) - pos - 2);
  substr_cpy(exponentString, numberString, pos + 2, 4,          elcount(exponentString));
  write("exponent string is %s", exponentString);
  exponentNumber = atol(exponentString);
  write("exponent number is %d", exponentNumber);
  
  for(i = 0; i < decimalPos; i++)
  {
    numberStringCorrected[i] = numberString[i];
  }
  
  for(i = decimalPos; i < pos -1; i++)
  {
    numberStringCorrected[i] = numberString[i + 1];
    counter++;
  }
  
  while(counter < exponentNumber)
  {
    numberStringCorrected[counter] = '0';
    counter++;
  }
  
  write("numberStringCorrected is %s",numberStringCorrected);
  numberNumber = _atoi64(numberStringCorrected);
  write("numberNumber is %I64d",numberNumber); 
  
}

 
 

 
Article Options
2020-02-06
Views: 76