# View topic - maths formula

## maths formula

3 posts
• Page

**1**of**1**### maths formula

I'll like to find out the correct writing of the syntax when i have the followings:

a=0xEA

b=0xFF

c=(a/b)*90

from normal calculations, changing all to decimal, I'll get 82.6, however this is not the case here. Can someone help me with the writing of this syntax so that i can at least get to 2 decimal place?

a=0xEA

b=0xFF

c=(a/b)*90

from normal calculations, changing all to decimal, I'll get 82.6, however this is not the case here. Can someone help me with the writing of this syntax so that i can at least get to 2 decimal place?

- rldchua
- New Member
**Posts:**7**Joined:**Thu Dec 11, 2003 5:48 am

int main (void)

{

float a=0x00;

float b=0x00;

float c;

sscanf("EA", "%X", &a);

sscanf("FF", "%X", &b);

c = (a/b) * 90;

printf("\n%f\n",c);

}

I'm assuming you're using C, there may be an easier way, but this seems to work.

HTH

Garry

{

float a=0x00;

float b=0x00;

float c;

sscanf("EA", "%X", &a);

sscanf("FF", "%X", &b);

c = (a/b) * 90;

printf("\n%f\n",c);

}

I'm assuming you're using C, there may be an easier way, but this seems to work.

HTH

Garry

- thegman
- Senior Member
**Posts:**439**Joined:**Sun Jun 15, 2003 8:10 pm

3 posts
• Page

**1**of**1**### Who is online

Users browsing this forum: No registered users and 1 guest