Discussion Forum

C CODE SNIPETS FOR GET PERTENTAGE

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
sohil ichan
Posted
7-Jul-2010 20:28 GMT
Toolset
C51
New! C CODE SNIPETS FOR GET PERTENTAGE

help me to get reduce code and time for simple percent = (value/256)*100

its work fine but i want to using fumnction pointers in arreays for divide and multiply.

Sohil I Chan

{power to the compiler}

Read-Only
Author
erik malund
Posted
7-Jul-2010 21:51 GMT
Toolset
C51
New! do not

using fumnction pointers in arreays for divide and multiply
the '51 architecture is singularily unsuited for function pointers and thus taking advantage of Keils admirable effort to squeeze them in will cost you more in aspirin than using them will save you in time.

Erik

Read-Only
Author
Andy Neil
Posted
7-Jul-2010 22:15 GMT
Toolset
C51
New! RE: i want to using fumnction pointers

Why do you want to use function pointers at all?

And why, particularly, on an 8051?

http://www.keil.com/appnotes/docs/apnt_129.asp

http://www.keil.com/support/man/docs/bl51/bl51_ol_fp.htm

etc, etc,...

Read-Only
Author
Hans-Bernhard Broeker
Posted
7-Jul-2010 22:55 GMT
Toolset
C51
New! RE: C CODE SNIPETS FOR GET PERTENTAGE

reduce code and time for simple percent = (value/256)*100

How about reducing errors first? That almost certainly needs to read (value * 100)/256. If you absolutely must micro-optimize that, try (value * 25u)/64u or (value * 25u)>>6, and pay special attention to your choice of data type for "value".

i want to using fumnction pointers in arreays for divide and multiply.

No, you don't. Seriously.

Next Thread | Thread List | Previous Thread Start a Thread | Settings