Unsigned Long Native Type

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Unsigned Long Native Type

Post 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
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Unsigned Long Native Type

Post 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).
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Post Reply