- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I would like to convert the Mantissa Result to the Decimal one with floating point included.

The steps I do: 1). I'm interested to divide two decimal numbers . For example 10 and 3 ===> 10/3 2). Using the Mega Wizard Core for conversion the decimal numbers to mantissa (ALTFP_CONVERT). 3). Dividing the mantissa result of 10 on the mantissa result of 3 by Mega Wizard Core (ALTFP_DIV). 4). The dividing result still presented in the mantissa form. 5). At the end i'd like to convert it back to the decimal form with floating point (to get 10/3 = 3.3). But the IP Core converting the result only into the decimal 3 and not into 3.3. The mantissa part was neglected, only the exponent part is taking the place. Am I making a mistake during the conversion steps? thanksLink Copied

5 Replies

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I don't know what you mean with "mantissa format". An IEEE float number is comprised of mantissa and exponent.

There's however no conversion to a fixed point decimal format provided. If you want to see something like 3.3, you need to multiply the float result with 10 (or 100, 1000, whatsoever) and convert back to integer. You get a result of 33, 333 or 3333 in your example, which can be interpreted as fixed point decimal format.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

That's exactly what I mean - mantissa format is the IEEE float number.

There is no other way to present the number 3.3? Only the multiplying? Thanksss- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

That's what e.g. a printf("%f", ) routine is supposed to do.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

If you want one digit to the right of the decimal point, then multiply the dividend by 10 prior to the division, then insert a decimal point before the last digit in teh output (or whatever).

ie use 'fixed point arithmentic'. Of course, depending on what you are doing, it might make more sense to multply by some power of 2.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Not that I have any clue why you are doing this but this might be easier:

1) 10/3 --> 3 and remainder 1 (use lpm_div) 2) 1(remainder from# 1)/3-->0.333333 (using altfp_convert followed by altfp_div) 3) 0.333333 * 10 (using altfp_mul) 4) 3.333333 convert to 3 to get the remainder with one decimal place (using altfp_convert to bring it back to a whole number) So step 1 gets you the digits to the left of the decimal place and steps 2-4 get you the first digit after the decimal place. That said this is a lot of hardware that I would normally just have a CPU calculate for me using software libraries.Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page