ATOF in vugen does not return a float.
Question ID: 105076

Whenever I use the atof function (such as atof("458.65");) it only returns the integer value only. I declare a variable of type float; however, it just doesn’t work in Vugen.

Marked as spam
Posted by (Questions: 23, Answers: 4)
Asked on July 22, 2013 4:17 pm
Answers (2)
Private answer

Please add the prototype for your function in the init section of your script. Please see the example below.

/*** Prototype for functions that don't return integers ***/

float atof(char *);



return 0;


Marked as spam
Posted by (Questions: 17, Answers: 266)
Answered on July 22, 2013 4:59 pm
Private answer

The prototype function is an excellent tip. You then have to do something like this:

char strNr[4]; // holds value of price while it is a string
char CStr[100]; // holds the string representation of the float
float i; // unit price as a floating point
float result =0; //

// ---------------------request comes here ------------------------

// copy param to string

strcpy(CStr, lr_eval_string(lr_eval_string(''{corr_param_UnitPrice}'')));

// copy string to floating point. Note you must have the prototype function above
i = atof(CStr);

// Perform the floating point calculation
result = (i * .35) + i;

// store increased price into formatted string
sprintf( strNr, ''%.2f'', result );

// store string in parameter
lr_save_string( strNr, ''corr_param_UnitPrice'' );

Marked as spam
Posted by (Questions: 0, Answers: 1)
Answered on April 26, 2017 6:32 pm

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

Scroll to Top