Searching \ for 'Displaying Mantissa and Exponent on an LCD' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/lcds.htm?key=lcd
Search entire site for: 'Displaying Mantissa and Exponent on an LCD'.

Truncated match.
PICList Thread
'Displaying Mantissa and Exponent on an LCD'
1999\04\05@172700 by Vogel, Alan

flavicon
face
Currently I am using the floating point math routines in Microchip AN575 and
converting the result to a 5 digit BCD number to display on a character LCD
module.  I would like to display the result in standard scientific notation.
Does anyone know a relatively easy way to convert the PIC floating point
base 2 format to a base 10 mantissa and exponent?

Alan

1999\04\05@195427 by Justin Crooks

flavicon
face
> Currently I am using the floating point math routines in Microchip AN575
and
> converting the result to a 5 digit BCD number to display on a character
LCD
> module.  I would like to display the result in standard scientific
notation.
> Does anyone know a relatively easy way to convert the PIC floating point
> base 2 format to a base 10 mantissa and exponent?


I've never tried this, but the math shouldn't be too difficult:
I'd create a routine that would take the float number , k, in the form (+-)
f x 2^n, and convert f into 2^x (where x is a float).  This can be
accomplished by using a small lookup table and linear approximation.
Add x and n, and the result leaves k in the form 2^x.
Multiply by 0.30103 (log 2), to convert this to 10^x.
Now, take the " f " portion of this float, and using a small lookup table
and linear approx. again, convert it to the mantissa.  The exponent portion
is actually 1 shy of what it should be if you're using Microchip's float
format.

This should give you 2 significant figures reliably if you use a 16-point
lookup table... I think

I'm sure someone out there has a better idea, but I don't mind starting the
thread :-)

1999\04\05@200054 by Gerhard Fiedler

picon face
At 14:11 04/05/99 -0700, Vogel, Alan wrote:
>Currently I am using the floating point math routines in Microchip AN575 and
>converting the result to a 5 digit BCD number to display on a character LCD
>module.  I would like to display the result in standard scientific notation.
>Does anyone know a relatively easy way to convert the PIC floating point
>base 2 format to a base 10 mantissa and exponent?

i don't know what routines are provided in that app note to do what you
want, but if you have a standard float representation, you usually have two
binary (signed) numbers: the mantissa and the exponent. you just have to
convert them separately to decimal/bcd, then you can display them in
standard float notation, ie. "0.6444e-55". the "0.6444" part and the "-55"
part are directly available (in binary) by extracting the appropriate bits
from the bit field representing the number. just convert them. have a look
at the way the routines store the float data, and you'll see what i mean.

ge

1999\04\05@200304 by Justin Crooks

flavicon
face
Oops, I thought you meant any floating point number.  For a 5-digit BCD, it
would be as easy as shifting the decimal and counting how far you had to
shift it...

----------
> From: Vogel, Alan <spam_OUTAVogelTakeThisOuTspamPACESETTER.COM>
> To: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
> Subject: Displaying Mantissa and Exponent on an LCD
> Date: Monday, April 05, 1999 3:11 PM
>
> Currently I am using the floating point math routines in Microchip AN575
and
> converting the result to a 5 digit BCD number to display on a character
LCD
> module.  I would like to display the result in standard scientific
notation.
> Does anyone know a relatively easy way to convert the PIC floating point
> base 2 format to a base 10 mantissa and exponent?
>
> Alan

1999\04\05@202548 by Vogel, Alan
flavicon
face
Thanks for the reply.  Unfortunately I think I would lose too much
resolution after using 2 lookup tables with interpolation.  I'm performing
math on a 12-bit signed number and would like to preserve the 3 and 3/4
digit display capability (e.g., three digits to the right of the decimal
point).

> {Original Message removed}

1999\04\05@203619 by Vogel, Alan

flavicon
face
Gerhard,

Thanks.  I was hoping there would be an easier way.  After I convert the
mantissa and exponent to decimal I still have to multiply them together
(because the exponent is in the form of 2^n) and then extract the exponent
by normalizing the result.

Alan

> {Original Message removed}

1999\04\05@204213 by Vogel, Alan

flavicon
face
You're right, but my 5-digit number is derived from a floating point to
integer conversion which doesn't always provide me with the resolution I
need.  I think maybe the fp to integer conversion I'm using should be
replaced with what Gerhard suggested.

Alan

> {Original Message removed}

1999\04\06@103712 by John Payson

flavicon
face
|Currently I am using the floating point math routines in Microchip AN575 and
|converting the result to a 5 digit BCD number to display on a character LCD
|module.  I would like to display the result in standard scientific notation.
|Does anyone know a relatively easy way to convert the PIC floating point
|base 2 format to a base 10 mantissa and exponent?

If speed is not critical, and if you don't mind having different
routines for the >=1 case and the <1 case, I'd suggest that you do
a variation of the BCD shift-and-add technique used elsewhere.  It's
not the most effecitent in terms of execution speed, especially with
large negative or positive exponents, but what you do is simply mult-
iply or divide the decimal representation by two the appropriate num-
ber of times.  If you're multiplying by two and you get a carry into
the leftmost digit (your buffer should be one digit larger than what
you're displaying) you should shift everything right one place and
add one to the [displayed] exponent; if you're dividing and you get
a zero in the leftmost place, shift left one place and subtract one
from the exponent.

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...