Samuel Dagan ha scritto:
>Hi Mario,
> It looks to me that this is a simple effect of round-off error, and
>this is not a bug. Each number is represented with a limited number
>of bits, and for a big number of decimal digits, you can enter in
>round-off errors.
> Cheers, Samy
>
>
>
Hello Samy!
Probably you didn't care so much about the effect...after my message I
tried some other experiment just to understand how to surrond the problem.
Try this:
s = "";
for (var i=0; i<50; i++) {
var v = i * 10e9;
s += v + "=" + parseFloat(v) + "\n";
}
alert(s);
You may notice that is NOT a round-off error!...
1) Internally, numbers are guaranteed to be double-precision from
(around) -1e308...-1e-308 and 1e-308...1e308
2) If you change the multiplying factor to (let's say) 100e12 (so
bigger) the result is correct
3) By using "parseFloat" on a numeric variable, I implicity use the
"toString()" method on it...It means that's wrong!...The
number-to-string conversion is buggy for numbers between 100 billions to
1000 billions!
4) Notice the conversion of 100 billions: it results zero!
What's I mistaken is that this behavior is only under thsi condition:
- script inside the SVG document;
- the script uses the ASV own's engine;
Yersteday I badly reported that it happens with MS engine also.
Ciao ciao
Mario
>--- In [email protected], "vernarim" <[EMAIL PROTECTED]>
>wrote:
>
>
>>Hello people...
>>Yersteday I spent almost four hours because my application was
>>misteriously shutting down (IDE included) every time the SVG picture
>>was shown.
>>I know that some components are touchy, but not as the yersteday
>>episode ;)
>>
>>Well, now copy and paste this small snippet on an empty text file
>>
>>
>and
>
>
>>then save it as TEST.SVG
>>Note: the test was conducted only with ASV 3.02
>>
>>
>>
>><?xml version='1.0'?>
>><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20001102//EN'
>>'http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd'>
>><svg xmlns:a3='http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/'
>>a3:scriptImplementation='Adobe'>
>>
>><script><![CDATA[
>>
>>function doit() {
>> // The following just to check the proper script engine running
>> try {
>> var t = ScriptEngine(); //Moz will fai this function
>> alert("MS!")
>> } catch(e) {
>> alert("Adobe!")
>> }
>>
>> // 180 millions
>> var v = 180000000;
>> v *= 100;
>> alert(v);
>>
>> // Just for verification...
>> v /= 1000;
>> alert(v)
>>}
>>
>>]]></script>
>>
>> <circle cx="100" cy="100" r="30" fill="blue" onclick='doit()'/>
>></svg>
>>
>>
>>Run the SVG with IE. With Mozilla is the same, but using IE you may
>>check the MS engine also.
>>As in the snippet, as soon you click the blue circle, a message pops
>>up showing you "Adobe!".
>>Once confirmed, another message will show 18 billions (18 followed
>>
>>
>by
>
>
>>9 zeroes) and finally the last pop up shows you 18000000.1
>>
>>Ok, now just try some other value instead of 100 as multiplier: I
>>suggest 10000, even it is a bit difficult to keep track of the
>>
>>
>zeroes.
>
>
>>Tried?...I know, it's correct!
>>
>>Now, PLEASE, try to use 1000 as multiplier!
>>I guess some of you, guys, have the eyes popped out the head!
>>
>>Isn't all!
>>Now, leaving 1000 as a multiplier, just modify the starting
>>value...for example using 170 millions or 190 millions...
>>You will notice that everything is ok.
>>
>>Of course, it is not because the multiplication, but because the
>>number itself. If you comment the multiplication writing the number
>>directly, the result is the same.
>>
>>Some other notes....
>>- If you try to change the script engine, nothing changes...at this
>>point I may think that the responsability could be in the APIs of
>>Windows...But, it's not so easy!
>>- Just cut the same script placing it inside another empty text file
>>and naming it as TEST.HTM (use a normal button to fire the
>>
>>
>function).
>
>
>>Everything goes ok, either for IE and for Moz...
>>
>>The final analisys is: this is a bug in ASV!
>>
>>I really hope that Adobe will correct it as soon as possible!
>>
>>Cheers from Venezia!
>>Mario
>>
>>
>>
>
>
>
>
>
>
>
>-----
>To unsubscribe send a message to: [EMAIL PROTECTED]
>-or-
>visit http://groups.yahoo.com/group/svg-developers and click "edit my
>membership"
>----
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/1U_rlB/TM
--------------------------------------------------------------------~->
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/