Hi, I have a floating point library for some time now, but hardly use it since fixed point is sufficient in most cases. What I have are + - / and * routines. The floats are stored in a dword, which makes it easy to handle in the application. You just need an assignement and retrieval funtion. A complex thing is proper printing. I only have a scientific (decimal) print function; all others can be done via scaled integers and format.jal.
IMHO we have a few different issues here: - conversion of inches to mm is just a case of proper scaling of fixed integers. I think a sample on how to do this is just as usefull for a user than an example of how to use a library. - fixed integer support routines are trivial as long as the scaling of the int's is the same. I can imagine that it would help users to have routines to handle this though. A well-designed API is mandatory. The most important thing required are printing routines that present the scaled integer in different ways. Format.jal is supposed to do this, but there are issues with this library and it could be extended. Note that the step from fixed point to floating point is not so big. Basically, you add the info on the scaling of the fixed point to the variable. One would however choose a ^2 scaling, while in fixed point ^10 scaling is common. My 2c Joep 2013/3/10 Sebastien Lelong <[email protected]>: > Hi guys, > > I'm playing with a sonar (Maxbotix EZ1). This sensor can give results in > inches. Which means nothing to me. So I was planning to create a "units.jal" > library, which would provide helpers for unit conversion. > > But how ?... > > function units_inches2cm(word in inchval) return dword is > ... > end function > > Several questions: > > - It takes a "word" as input, so should return a dword since 1 inch = 2.54 > cm. But it could also take a dword. or a 5*byte, etc... How should we deal > with this ? As in print.jal, with type dedicated function ? > (units_dword_inch2cm, units_word_inch2cm, etc...) > > - how should we deal with floating point values ? For the cm2inch > conversion, there could be such values involved. Can jalv2 record help ? > > record fp is > word mantissa > word exponent > end record > > or > > record fp is > word before_point > word after_point > end record > > such record would then be used by print.jal, etc... > > > Any hints, ideas, suggestions ? > > Let's not talk about how greedy it would be, how much memory and computation > it would need... > > Cheers > Seb > > -- > Sébastien Lelong > > -- > You received this message because you are subscribed to the Google Groups > "jallib" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/jallib?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/jallib?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
