Hi guys,

How can we proceed ? In my original post, there are two points: unit
conversion, and floating point (or fixed point, I'm not sure now :)).
Choosing units is just a matter of agreement (though it could be hard)

Joep, you say you store floats in a dword, but how do you specify the
mantissa/exponent ? Is it somewhat coded ?

Cheers,
Seb



On 10 March 2013 12:59, Joep Suijs <[email protected]> wrote:

> 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.
>
>
>


-- 
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.


Reply via email to