Hi, Op vrijdag 27 januari 2012 schreef Oliver Seitz ([email protected]) het volgende: > Hi! > >> var float x >> x = (adc_read(channel) * 12)/1023 >> print_float_dec(serial_hw_data,x) > > You don't need floats for that, you can do it in fixed point. The JAL compiler, unlike most other compilers, supports integer variables of arbitrary size. You need 50 decimal places before and 50 after the point? Fine! Define
Long vars are a true advantage. However, use them as a substitute for float does require a lot more attention: - you need to plan for the max used value and the min required accuracy. - you need to manual track the fixed point position of a variable and correct it at each multiply/divide - if you have vars with different fixed point settings, you need to correct for this before add/ subtract. - assing and print properly is not as obvious as real floats. It might be possible to implement floats in a library and use a large variable ( or struct?) to store it and pass it to functions. Most of such a library would be straightforward. The main issue would be to maintain the optimal exponent. > > var byte*42 x > > and store the value multiplied by 10^50. Addition and subtraction can be done right away. Multiplication and division needs adjustment, but that's not hard. I'm thinking about a lib for that for some time now... > >> var string s >> s = 'Hello' >> s = s + 'world' Print_string(serial_hw_data, 'hello JAL world.') would be a start. It is a personal feature request from the moment strings were introduced but has not been implemented in all those years. Since this would be much more commonly used than features like structs, i assume it is complex to extend string support. Now, it does not even match the primitive string support of C... Joep -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
