Reply by Johnson, Jerry March 1, 20042004-03-01
RE: [motoroladsp] fractional number

Frac16 and Fract32 are representations of the values +1.0 to -1.0 so to convert them to an integer, just multipy them by the range you wish to represent.

For example: to have a range of -100 to 100, multiply the Fractxx value by 100.

Another way to look at this is to think in terms of the following equation:
 Fract = (integer value)/(maximum integer value)

So, multiplying a Fract16 by the maximum integer value yields the represented integer value.

If your range of integer values happens to be +32767 to -32768, then the Fract16 value is the corresponding integer value!!!

Jerry.



-----Original Message-----
From: bblaundry [mailto:b...@microwavedata.com]
Sent: Monday, March 01, 2004 1:17 PM
To: m...@yahoogroups.com
Subject: [motoroladsp] fractional number


Hello All,

I am having trouble working with fractions within my project.  I am
using a DSP56F826 chip with Codewarrior tools.

I am trying to create functions that will convert fractional data
(Frac16 and Frac32) into int and long int data.

Does anyone know how to do this either in C or in assembly?

Thanks,

Brad



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cidU11
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/PNArlB/TM
---------------------------------~->

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:  m...@yahoogroups.com

To Post:  m...@yahoogroups.com

To Leave: m...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/motoroladsp

More Groups: http://www.dsprelated.com/groups.php3
 
Yahoo! Groups Links


 


________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information visit http://www.messagelabs.com
________________________________________________________________________


________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information visit http://www.messagelabs.com
________________________________________________________________________
Reply by Estevam Fabio-R49496 March 1, 20042004-03-01
Brad,

Maybe you can use the following macros provided in SDK to assist you in the
conversion from fractional to integer:

#define FRAC16(x) ((Frac16)((x) < 1 ? ((x) >= -1 ? (x)*0x8000 : 0x8000) :
0x7FFF))
#define FRAC32(x) ((Frac32)((x) < 1 ? ((x) >= -1 ? (x)*0x80000000 : 0x80000000)
: 0x7FFFFFFF))

and as an example you can use them as:

UWord16 Int16 = FRAC16(0.25)
UWord32 Int32 = FRAC32(0.75)

Hope this helps.

Best regards,

Fabio Estevam

-----Original Message-----
From: bblaundry [mailto:]
Sent: segunda-feira, 1 de mar de 2004 16:17
To:
Subject: [motoroladsp] fractional number Hello All,

I am having trouble working with fractions within my project. I am
using a DSP56F826 chip with Codewarrior tools.

I am trying to create functions that will convert fractional data
(Frac16 and Frac32) into int and long int data.

Does anyone know how to do this either in C or in assembly?

Thanks,

Brad

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/motoroladsp

More Groups: http://www.dsprelated.com/groups.php3

Yahoo! Groups Links


Reply by bblaundry March 1, 20042004-03-01
Hello All,

I am having trouble working with fractions within my project. I am
using a DSP56F826 chip with Codewarrior tools.

I am trying to create functions that will convert fractional data
(Frac16 and Frac32) into int and long int data.

Does anyone know how to do this either in C or in assembly?

Thanks,

Brad