Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function to retrieve Decimal Places
Message
From
30/06/2009 10:57:41
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01409350
Message ID:
01409365
Views:
72
>Yuri:
> Thanks. I thought about that, but I'd really like to just do everything in one step, without having to use an array.
>
>Jerry


Try this - it won't work if total # of digits > 18 - as it then switches to scientific notation (eg 1e19)
create cursor pp ;
	(	field1 N(6,2), ;
		field2 b(6) ;
	) 
	append blank
	
	?Number_Digits_FractionalPart(field1 )
	?Number_Digits_FractionalPart(field2 )

function Number_Digits_FractionalPart(n)
	
	if( !inlist(vartype(m.n), T_NUMERIC, T_CURRENCY, T_FLOAT, T_DOUBLE) )
		assert FALSE
		return 0
	
	endif

	return len(rtrim(justext(strtran(padl(m.n, 30), set('point'), '.'))))	
endfunc
*---------------------------------------------------------------------------
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform