F32 - 90 minutes of fun - user caveat
g3cwi
Posts: 262
...before realising that Fmul(32.5 * 10) did not work because it was not Fmul(32.5 * 10.0). You cannot begin to imagine how many things I have tried!
Grrrrr. More beer.
Cheers
Richard
Grrrrr. More beer.
Cheers
Richard
Comments
Oh yes I can. For I have been there. And done that.
More than I care to admit.
Hey, wait a second. Are you using the FloatMath object or what??
It's at times like this you wish that Spin had proper types.
I just started learning Javascript for the first time where there are similar problems. OK JS has integers and floats but it will silently convert numbers to strings when using the "+" operator. So:
a = 2;
b = "2";
c = a + b;
d = a * b;
Makes c equal to the string "22"
But d equal to the number 4.
The reason I asked is because the only float math objects I know about don't use an asterisk, they use a comma.
So it wouldn't be Fmul(32.5 * 10.0)
Instead it would be Fmul(32.5, 10.0)
But maybe you guys have some object I don't know about?
Just a typo on my behalf in the OP.
Cheers
Richard
A general problem with Spin is that it doesn't support floating point directly, but many compiler constants (e.g. Pi) are expressed as floating point. The Spin pre-processor can also construct floating point constants so you get lured into using floating point when it would probably be better to use a fixed point solution. For example Trig on the Basic Stamp is done entirely using integer math and binary radians, so Spin could be improved if a good fixed point math package exited.
BTW I did find a fixed point library in the OBEX, but it was written in Spin and was slower than F32.
Update: The original poster said it was a typo and they used a comma, so it wasn't fixed by the pre-processor.
Grr Argh JavaScript! I hate that language with the heat of a billion exploding Suns!
* Did you know that "var undefined = 1;" will work in JavaScript and then break all code that tests against undefined? This is because undefined is not a keyword like null, but an undefined variable.
* That myVar === undefined is the preferred way to test for undefined. No that's not a typo it's a triple equal which is the strict comparison operator which doesn't type convert by default.
* Pointers can be either undefined or null, so you need to check for both everywhere!
* JavaScript uses 64 bit reals for all numbers which means that you can write for loops that won't terminate due to truncation errors!
* It's object system is sort of cool in a language geek sort of way because it's really an OO construction toolkit. This means you get to build your own OO type system from it. The problem is everyone builds their own so nothing interoperates.
It's easy to write simple stuff (parameter validation, dynamic web forms, etc), but extremely difficult to write reliable large systems in it. There's also a fairly large number of people in the web programming community thinking that every thing should be written in it.
I've been avoiding JS for donkeys years. Just now I started looking into it for stuff at work so...
Thanks for the heads up on that. Even jslint checks out OK when you do that! Luckily my syntax highlighting editor (vim) colors "undefined" as a key word.
Yes, but this is an issue in any language with floats. Things that you think should be equal may not be. On the plus side integer values go to 2^53 even on 32 bit machines.
Yeah, that is as confusing as hell.
I would have thought so, but then there I guys doing things like this http://qooxdoo.org/
Perhaps the approach is "don't write large systems in it". Rather create a lot of small inter-operating parts.
Looking at it as a "WEB programming outsider" I have always thought that everything about WEB programming sucked. On the browser you have a mess of HTML, the toy JS language, CSS, the DOM ,,,gack. On the server side you have a mess of Apache, the toy PHP language (and others), templating systems etc etc etc. All this chaos hooked up with a bunch of odd protocols and XML (more gack). Looking at this Tower of Babel I wonder how they get anything to work:)
Would it not be better to have the same language on all nodes in the system no matter if they are servers or browsers or whatever?
Enter JS on the server. Which I found in one case is faster than our old C++ implementation with one fourth the amount of code and a lot easier to modify.
Jonathan