hardware floating point binary to decimal (7 seg LED) displays

Thread Starter

hoi2you

Joined Dec 2, 2017
15
How do computers calculators convert floating point binary to a format that can be read by LED displays. Note that I know the theory of the conversion process and I know about the conversion from binary to the 7 seg display , what I do not understand is how we get from floating point binary to a format that the displays can handle. Is this done in software ?
I want to build a conversion circuit in logisim from 32 bit floating point binary to a set of 7 seg displays.

Thank you.
 

WBahn

Joined Mar 31, 2012
25,764
Like most things, it can be done in either hardware or software or come combination of the two.

To do the conversion you are discussing, you need to first very clearly define what your "set" of 7 seg displays consists of and how you are going to display values.

How do you want 1 represented on this set of displays?

How do you want -15.6 to be displayed?

How do you want 2.38475 x 10^27 to be displayed?

How do you want -0.000000000000000172647 displayed?
 

Thread Starter

hoi2you

Joined Dec 2, 2017
15
Hi there. Yes it's a bit of an open ended question. So let's say I want to just represent one floating point number say 0 10000001 0100 1100 1100 1100 0011 001 which is 5.2 , how do I get this 32 bit number to display 5.2. Do I first convert it to binary or BCD or some other form ?
 

WBahn

Joined Mar 31, 2012
25,764
Hi there. Yes it's a bit of an open ended question. So let's say I want to just represent one floating point number say 0 10000001 0100 1100 1100 1100 0011 001 which is 5.2 , how do I get this 32 bit number to display 5.2. Do I first convert it to binary or BCD or some other form ?
But it ISN'T 5.2, it's 5.199963092803955....

So why do you want it to display 5.2?

What would you want it to display if you had meant for the value to be 5.1875? Would you want that displayed as 5.2 as well?

It can't remain an open-ended question. You have to decide what the rules are that you want to use to display the values. Without having a completely specified outcome, there is no way to design either a circuit or a program to achieve that outcome.
 

ci139

Joined Jul 11, 2016
1,464
extract the sign , convert it to integer (keeping track of the binary point - depending on the "display mode" scientific/decimal)
with the scientific mode a hell gets loose getting the log.10 right for large/small numbers . . . there might be some special algorithms worked out for . . . that actually won't use the built in FP functions but depending on the format convert the 32-bit FP to ±x.xxx... E ±yyy form (the newer FP software might also include such by default)

? https://www.mathworks.com/help/matlab/ref/num2str.html (i don't use matlab nor modern MCU-s)
...
http://www.avr-asm-tutorial.net/avr_en/calc/CONVERSION.html
https://www.avrfreaks.net/forum/how-convert-float-string \(\leftarrow\) this is not what you wanted - but if you have the source of such - you can mod it for the FP BCD
 
Last edited:

WBahn

Joined Mar 31, 2012
25,764
Yes sorry I should have said the 32 bit floating point approximation to 5.2
But that gets right at the heart of the matter. If your system sees that bit pattern, how is it supposed to know that it should display 5.2 and not 5.19996 or 5.20 or even just 5?
 

Thread Starter

hoi2you

Joined Dec 2, 2017
15
Ok let's say it should display the decimal equivalent to the IEEE754 standard 32 bit floating point binary number.
 

jpanhalt

Joined Jan 18, 2008
9,426
Hi there. Yes it's a bit of an open ended question. So let's say I want to just represent one floating point number say 0 10000001 0100 1100 1100 1100 0011 001 which is 5.2 , how do I get this 32 bit number to display 5.2. Do I first convert it to binary or BCD or some other form ?
It appears you may be asking to round and display a fixed decimal point.

Please give some other examples, say 4 or 5, of 32-bit floating point numbers and what you want to display.
 

Thread Starter

hoi2you

Joined Dec 2, 2017
15
Yes . I chopp off any bits beyond 32 equivalent to rounding all numbers down ).
Thank you people for taking the time. WBahn Im sure your trying to tell me something perfectly valid but I may have to sleep on it for the night.
I have created a conversion tool in VBA (I would send the tool but don't think you can attach executables ?). Here are some of the values (they match with other online conversion tools) attached. I enter the 32 bit binary at the top and it gives me the decimal value below. I also added in the workings of the conversion.
 

Attachments

Thread Starter

hoi2you

Joined Dec 2, 2017
15
I am trying to build a hardware realised version of this in logisim. I will allow myself to use all available logisim components. I have built a BCD to decimal converter and straight binary to decimal converter (using double dabble algorithm) both in logisim and I am now trying to build a binary floating point to decimal converter in logisim. I will simplify the rounding ans assume everything is rounded down.
 

jpanhalt

Joined Jan 18, 2008
9,426
You want to suppress trailing zeros?

Why not just use a very simple, round routine (e.g., always up, always down, or >= "5" round up, etc.), and report a fixed one-decimal point, e.g., "2" would display as "2.0" and so forth? It seems wasteful to have only 1 significant figure for a 32-bit input.
 

Thread Starter

hoi2you

Joined Dec 2, 2017
15
I mean I will chop off from the 33rd bit so I still get a vallue close to what the IEEE standard says. I will emply the actual IEEE rounding standard at some point but for now I want to keep it as simple as I can.
 

jpanhalt

Joined Jan 18, 2008
9,426
Hi there. Yes it's a bit of an open ended question. So let's say I want to just represent one floating point number say 0 10000001 0100 1100 1100 1100 0011 001 which is 5.2 , how do I get this 32 bit number to display 5.2. Do I first convert it to binary or BCD or some other form ?
But that is inconsistent with what you just posted. Do you see the inconsistency? Which is it?
 

Thread Starter

hoi2you

Joined Dec 2, 2017
15
I'm just no closer to getting my head round how to proceed. Maybe a good sleep and a fresh head will help me ! I have no problems creating circuits for add /sub / mult / div floating point binary numbers but coming out of floating point binary land to a bank of segment displays representing decimal values has me a bit stumped !
 

jpanhalt

Joined Jan 18, 2008
9,426
Yes point taken it is actually 5.199999809265145 which is my rounded down approximation to 5.2
Confused? 5.1999 ... rounded down to two significant figures is 5.1.

I think you need to sit back and envision what you really want to do. Then come back with an explanation and examples.
 

Thread Starter

hoi2you

Joined Dec 2, 2017
15
Ahh ok. I'm not rounding it down to 2 significant figures. I'm rounding it down to the decimal value you get when you use a 32 bit binary floating point approximation.
 
Top