This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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}

Parents
  • 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.

Reply
  • 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.

Children
No data