As the code is open it should be possible to adapt, but you should test if the number fits into a float or in a long.

there exist - long bc_num2long (num) - which you can use as an example how to convert float.

long

bc_num2long (num)

bc_num num;

{

long val;

char *nptr;

int index;

/* Extract the int value, ignore the fraction. */

val = 0;

nptr = num->n_value;

for (index=num->n_len; (index>0) && (val<=(LONG_MAX/BASE)); index--)

val = val*BASE + *nptr++;

/* Check for overflow. If overflow, return zero. */

if (index>0) val = 0;

if (val < 0) val = 0;

/* Return the value. */

if (num->n_sign == PLUS)

return (val);

else

return (-val);

}

From the code you see it is tried to convert the value and if it not succeeds it returns 0 - which is imho a bug in the interface as 0 is a valid long.

Better interface would be returning a bool indicating if the conversion worked.

For floats you could return the value INF or NAN if out of range .. nay better a bool.

snippet

bool bc_num2float(bc_num num, float *f)

{

if (abs(bc_num) > MAXFLOAT) return false;

...

f = ..;

return true;

}

hopes this gets you started...