int/uint comparison F10

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

int/uint comparison F10

victor / tokiop
Hi List !

I'm trying to compile fogg for flash10 with Haxe 2.0.4, to test a  
mixed mp3/ogg player,
but i get a few compilation errors, and don't find how to cleanly  
solve this one:

"comparison of Int and Uint may lead to unexpected results"

I started Std.int() every Uint but they are used in comparison in a  
lot of classes so it must
not be the way to go for performance and future updating..

Found out that this issue was fixed in version 2.0.4 for flash9, but  
is their a way for
flash 10? Is it a compiler issue or my misunderstanding of flash10  
uint handling ?

Thanks for any ideas !

Victor

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: int/uint comparison F10

Cauê W.
Hey, victor!

If you're worried about performance, you -could- use the untyped keyword, but only if you can guarantee that the uint will be assigned positive values only, and it's best that it stays between the int boundaries, otherwise it will lead to some unexpected results, by definition:

        var test:Int = -1;
        var test2:UInt = -1;
       
        trace(test >= untyped test2); //false

        trace(test == untyped test2); //false
       
        trace((untyped test2) > test); //true
       
        trace ((untyped test2) == -1); //false
       
        trace(test); //-1
        trace(test2); //4294967295

2009/11/2 victor / tokiop <[hidden email]>
Hi List !

I'm trying to compile fogg for flash10 with Haxe 2.0.4, to test a mixed mp3/ogg player,
but i get a few compilation errors, and don't find how to cleanly solve this one:

"comparison of Int and Uint may lead to unexpected results"

I started Std.int() every Uint but they are used in comparison in a lot of classes so it must
not be the way to go for performance and future updating..

Found out that this issue was fixed in version 2.0.4 for flash9, but is their a way for
flash 10? Is it a compiler issue or my misunderstanding of flash10 uint handling ?

Thanks for any ideas !

Victor

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: int/uint comparison F10

Nicolas Cannasse
In reply to this post by victor / tokiop
victor / tokiop a écrit :

> Hi List !
>
> I'm trying to compile fogg for flash10 with Haxe 2.0.4, to test a mixed
> mp3/ogg player,
> but i get a few compilation errors, and don't find how to cleanly solve
> this one:
>
> "comparison of Int and Uint may lead to unexpected results"
>
> I started Std.int() every Uint but they are used in comparison in a lot
> of classes so it must
> not be the way to go for performance and future updating..

Std.int() to convert an UInt should not have any impact on performances.
But I wonder what kind of operations you are doing. Could you give some
simple examples ?

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: int/uint comparison F10

victor / tokiop
Thanks for your advices guys !

Hi Couê, indeed the results look strange, thanks for the examples !

Nicolas :
> Std.int() to convert an UInt should not have any impact on  
> performances.
> But I wonder what kind of operations you are doing. Could you give  
> some simple examples ?

i'm trying to compile fogg to test ogg files playback : https://launchpad.net/fogg

It looks like it was written before 2.0.4 because there is a few  
compile errors on my side,
for example in org/xiph/fvorbis/Block.hx :

             if ((pcm[i] == null) || (pcm[i].length < pcmend)) {   <----
                 pcm[i] = new Vector(pcmend, true);
             }

pcm[i].length is UInt versus pcmend which is Int. Both must be  
positive so untyped might
also work in that context.

It looks like the same issue edA-qa mort-ora-y was talking about here:
http://lists.motion-twin.com/pipermail/haxe/2009-July/027907.html

If Std.int does not affect performance and look like the best way to  
go I will update it like that,
but since there is quite a few comparisons and classes i prefer to ask  
before doing dirty coding
on this useful lib !

Victor


Le 3 nov. 09 à 10:22, Nicolas Cannasse a écrit :

> victor / tokiop a écrit :
>> Hi List !
>> I'm trying to compile fogg for flash10 with Haxe 2.0.4, to test a  
>> mixed mp3/ogg player,
>> but i get a few compilation errors, and don't find how to cleanly  
>> solve this one:
>> "comparison of Int and Uint may lead to unexpected results"
>> I started Std.int() every Uint but they are used in comparison in a  
>> lot of classes so it must
>> not be the way to go for performance and future updating..
>
> Std.int() to convert an UInt should not have any impact on  
> performances.
> But I wonder what kind of operations you are doing. Could you give  
> some simple examples ?
>
> Nicolas
>
> --
> haXe - an open source web programming language
> http://haxe.org
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: int/uint comparison F10

victor / tokiop
ok, with Std.int(UInt) fogg compiles ok now,
thanks for your quick help !

Victor


--
haXe - an open source web programming language
http://haxe.org