Hi Seb!
> >record fp is > word mantissa > word exponent >end record > > >or > > >record fp is > word before_point > word after_point >end record > > > >The second version is not floating point, but yet another type of fixed point. >I do prefer fixed point, but not in such a way that even addition and >subtraction has to be treated specially. For imperial units use mils, for >metric units use micrometers. We could define the fixed-point variable size as >dword, that makes the values go to like 1000 million kilometers. If you would prefer to really use floating-point variables, I'd highly object to use any composed units like centimeters or milliamperes in a library. There's no reason then to use anything else than meter or ampere. (We can discuss the unit of mass again, as it's "kilogram" in the SI definition... ;-) ) This is how I'd see a fixed-point library... const fp_accuracy=1_000_000-- = length unit is micrometers const fp_size=4 const factor_inch_to_meter=393701 function fp_multiply(byte*fp_size in factor1, byte*fp_size in factor2) return byte*fp_size is return byte*fp_size( (byte*(fp_size*2)(factor1) * factor2) / fp_accuracy ) end function division is similar. Addition and subtraction can be done just like var1+var2, and so is comparison. Setting direct values needs attention: const unit_micro=1 const unit_milli=1000 const unit_centi=10000 const unit_deci=100000 const unit_one=1000000 const unit_deca=10000000 const unit_hecto=100000000 const unit_kilo=1000000000 const unit_mega=1000000000000 var byte*fp_size threshold= 4 * unit_centi -- 4 centimeter to print a value in mm, do like print_fp(output,fp_multiply(inch_value,factor_inch_to_meter*unit_milli)) Greets, Kiste -- 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.
