Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Problem with Single variable
Goto page Previous  1, 2
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
SZTRAD

Bascom Member



Joined: 30 Dec 2019
Posts: 165

blank.gif
PostPosted: Sat Apr 24, 2021 9:50 am    Post subject: Reply with quote

Well, I didn't want to anymore, but now I'm going to answer.
It's not that simple (which is also in life).
The basic definition was given by IEEE 754-1985(https://standards.ieee.org/standard/754-2019.html) standard extended in 2008 and last I guess 2019.
If we look at the first extension in 2008 it defined the numbers this way(I will allow the tables to remain in my language)
Figure1.

Which represents the range
fig2.

Ways to store floating point numbers
Computer systems take advantage of the fact that a selected subset of real numbers can be expressed as

XFP = (-1)S × bexponent-bias × m

Different computer systems use different bases, and different representations of the mantissa and exponent
Fig3


The creator of the system that probably most of us use for the basic one says this
https://docs.microsoft.com/en-us/office/troubleshoot/access/floating-calculations-info
and admits to not following the standard
https://docs.microsoft.com/en-us/office/troubleshoot/excel/floating-point-arithmetic-inaccurate-result

Anyone who uses C or C++ for programming knows that they have to decide what they want at the beginning of their own program. Turning translation optimization on to the expected result can mess with your head pretty good.
It's even more interesting with interpreted languages. For example, Python 2 behaves quite differently than Python3 when rounding.

It's just a fringe thing, and he knows I'm way off topic.
Those of us who do this for a living already know this(and that it costs a lot of nerves) and the rest of us have to put up with it. It is interesting that even the manufacturers of the various PLCs each take a different approach to the problem and prefer not to point it out. Such a PID control setup is often nerve wracking.
RS
Back to top
View user's profile
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Sat Apr 24, 2021 3:30 pm    Post subject: Reply with quote

Somehow NASA sent Apollo 11 to the moon and back using 16 bit, 2MHz, and 2K RAM.

It appears the user is more important than bits?

E
Back to top
View user's profile
SZTRAD

Bascom Member



Joined: 30 Dec 2019
Posts: 165

blank.gif
PostPosted: Sun Apr 25, 2021 7:50 am    Post subject: Reply with quote

Hi
Well, mistakes have been made here too.
One that interprets the problem discussed here is written in Ada.

L_M_BV_32 := TBD.T_ENTIER_32S ((1.0/C_M_LSB_BV) * G_M_INFO_DERIVE(T_ALG.E_BV));

if L_M_BV_32 > 32767 then
P_M_DERIVE(T_ALG.E_BV) := 16#7FFF#;
elsif L_M_BV_32 < -32768 then
P_M_DERIVE(T_ALG.E_BV) := 16#8000#;
else
P_M_DERIVE(T_ALG.E_BV) := UC_16S_EN_16NS(TDB.T_ENTIER_16S(L_M_BV_32));
end if;

P_M_DERIVE(T_ALG.E_BH) :=
UC_16S_EN_16NS (TDB.T_ENTIER_16S ((1.0/C_M_LSB_BH) * G_M_INFO_DERIVE(T_ALG.E_BH)));

RS
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum