Page 2 of 2

Re: Unsigned Long Native Type

Posted: Sat Jun 18, 2016 11:27 am
by #NULL
Keya wrote:ps. Purebasic is able to automatically handle conversion between signed/unsigned BYTE (.a/.b) and WORD (.w/.u), no casting required, so if it can already do such seamless conversions with 8 and 16bit i dont understand why the same approach cant be extended to 32bit :( :)
what do you mean by that? without an assignment operator everthing just gets casted to integer (in most cases i think) so the (a-1) in the if does not respect the type of a.

Code: Select all

a.a = 0
b.b = 0

Select 3
    
  Case 1
    a-1
    b-1
    Debug a   ; 255
    Debug b   ; -1
    
  Case 2
    Debug a-1   ; -1
    Debug b-1   ; -1
    
  Case 3
    If (a-1)=255 And (b-1)=-1
      Debug "x"
    Else
      Debug "got here"
    EndIf
    
EndSelect

Re: Unsigned Long Native Type

Posted: Sat Jun 18, 2016 7:23 pm
by Lunasole
Keya wrote:btw how does VB.Net handle conversions between Long<>Dword? like does it require casting or is it automatic or..?
I asked friend, he tells that VB.NET allows any type conversion be transparent to a programmer, including float <> int but excluding "string <> number conversion".
Both ways of conversion (using plain "=" or system functions) are valid and legit anyway, but with "=" compiler shows warning in cases when conversion leads to variable "trimming" (like float to int conversion or uint to int), that's because of some .NET internal crap related to localization/region settings (possible difference with float rounding, etc, the system functions are handling this, assignment operator - not).