JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
Okay,
32 bit Signed/unsigned
16 bit signed/unsigned
8 bit signed/unsigned
THis is a standard in a COMPUTER - not a language
SByte Signed 8-bit -128 to 127
Byte Unsigend 8 bit 0 to 255
11111111 = -1 or 255 dependent upon which "type" you use.
So why can't i do this:
That defies the concept of using a computer in the first place. A bit is a bit is a bit, it doesn't matter what language is interpreting it. and for those that can't think in "concepts" here is the code i'm trying to do:
From this I am using the High Word (upper 16 bits) as the Row indicator, and the Low Word (lower 16 bits) as the Column indicator. If the Row and/or Column are -1 then they represent property items for rows, columns, or for the entire grid. (please don't tell me that something else exists to do this because i don't care. I want to learn the language and by writing things myself I get better in understand the flaws and virtues - if they exist - of a new language).
So Upon grid creation I am creating a THashKey descentent that tries to call this:
This, should set the two parts of f_Hash to the appropriate values affecting the BITS not the "typed value" and being a 32-bit unsigned integer, converting -1 to a UShort (16 bit unsiged) should equate to 65535, shift left 16 and thus in the end the value of f_Hash after setting the High Word to -1 and the Low Word to -1 should be:
4,294,967,295
So, why won't it let me BITWISE manipulate these items. This is fundamental to what a computer is, and i'm quite tired of the supposed "high level languages" preventing me from manipulating them at the most basic level. Perhaps i'm using the wrong types to achieve this, but I don't quite see why I should need to use a 64 bit to retain what I can use a 32 bit to do.
*shrug*
Tis just frustrating, because C, C++, Pascal, even Fortran can do this, though Fortran might not be up to the 32 bit technology *chuckle*
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
32 bit Signed/unsigned
16 bit signed/unsigned
8 bit signed/unsigned
THis is a standard in a COMPUTER - not a language
SByte Signed 8-bit -128 to 127
Byte Unsigend 8 bit 0 to 255
11111111 = -1 or 255 dependent upon which "type" you use.
So why can't i do this:
VB.NET:
dim value as integer = -1
dim x as UInteger
x = CUint(value)
That defies the concept of using a computer in the first place. A bit is a bit is a bit, it doesn't matter what language is interpreting it. and for those that can't think in "concepts" here is the code i'm trying to do:
VB.NET:
Public MustInherit Class THashKey
Public Shared ReadOnly S_HW As Integer = 16
Public Shared ReadOnly S_HWHB As Integer = 24
Public Shared ReadOnly S_LWHB As Integer = 8
Public Shared ReadOnly C_HW As Integer = 65535 << S_HW
Public Shared ReadOnly C_LW As Integer = 65535
Public Shared ReadOnly C_HWHB As Integer = 255 << S_HWHB
Public Shared ReadOnly C_HWLB As Integer = 255 << S_HW
Public Shared ReadOnly C_LWLB As Integer = 255
Public Shared ReadOnly C_LWHB As Integer = 255 << S_LWHB
Public Enum KeyBytes
kbValue
kbHW
kbLW
kbHWHB
kbHWLB
kbLWHB
kbLWLB
End Enum
Private f_Hash As UInteger
Public Sub New()
End Sub
Public Sub New(ByVal iHash As UInteger)
f_Hash = iHash
End Sub
Public Property HW() As UShort
Get
Return CUShort((f_Hash And C_HW) >> S_HW)
End Get
Set(ByVal value As UShort)
f_Hash = CUInt(LW) Or (CUInt(value) << S_HW)
End Set
End Property
Public Property LW() As UShort
Get
Return CUShort(f_Hash And C_LW)
End Get
Set(ByVal value As UShort)
f_Hash = (CUInt(HW) << S_HW) Or CUInt(value)
End Set
End Property
Public Property HWHB() As Byte
Get
Return CByte((f_Hash And C_HWHB) >> S_HWHB)
End Get
Set(ByVal value As Byte)
f_Hash = CUInt(LW) Or (CUInt(HWLB) << S_HW) Or (CUInt(value) << S_HWHB)
End Set
End Property
Public Property HWLB() As Byte
Get
Return CByte((f_Hash And C_HWLB) >> S_HW)
End Get
Set(ByVal value As Byte)
f_Hash = CUInt(LW) Or (CUInt(HWHB) << S_HWHB) Or (CUInt(value) << S_HW)
End Set
End Property
Public Property LWHB() As Byte
Get
Return CByte((f_Hash And C_LWHB) >> S_LWHB)
End Get
Set(ByVal value As Byte)
f_Hash = (CUInt(HW) << S_HW) Or CUInt(LWLB) Or (CUInt(value) << S_LWHB)
End Set
End Property
Public Property LWLB() As Byte
Get
Return CByte(f_Hash And C_LWLB)
End Get
Set(ByVal value As Byte)
f_Hash = (CUInt(HW) << S_HW) Or (CUInt(LWHB) << S_LWHB) Or CUInt(value)
End Set
End Property
Default Public Property Value(ByVal part As KeyBytes) As UInteger
Get
Select Case part
Case KeyBytes.kbValue : Return f_Hash
Case KeyBytes.kbHW : Return HW
Case KeyBytes.kbHWHB : Return HWHB
Case KeyBytes.kbHWLB : Return HWLB
Case KeyBytes.kbLW : Return LW
Case KeyBytes.kbLWHB : Return LWHB
Case KeyBytes.kbLWLB : Return LWLB
End Select
End Get
Set(ByVal value As UInteger)
Select Case part
Case KeyBytes.kbValue : f_Hash = value
Case KeyBytes.kbHW : HW = CUShort(value)
Case KeyBytes.kbHWHB : HWHB = CByte(value)
Case KeyBytes.kbHWLB : HWLB = CByte(value)
Case KeyBytes.kbLW : LW = CUShort(value)
Case KeyBytes.kbLWHB : LWHB = CByte(value)
Case KeyBytes.kbLWLB : LWLB = CByte(value)
End Select
End Set
End Property
Friend Overridable Sub Copy(ByVal value As THashKey)
If value IsNot Nothing Then f_Hash = value.f_Hash
End Sub
Public Overridable Function Init(ByVal ParamArray args() As Object) As THashKey
If (args.Length >= 1) AndAlso IsNumeric(args(0)) Then
f_Hash = CUInt(args(0))
End If
Return Me
End Function
End Class
From this I am using the High Word (upper 16 bits) as the Row indicator, and the Low Word (lower 16 bits) as the Column indicator. If the Row and/or Column are -1 then they represent property items for rows, columns, or for the entire grid. (please don't tell me that something else exists to do this because i don't care. I want to learn the language and by writing things myself I get better in understand the flaws and virtues - if they exist - of a new language).
So Upon grid creation I am creating a THashKey descentent that tries to call this:
VB.NET:
Me.Value(KeyBytes.kbHW) = -1
Me.Value(KeyBytes.kbLW) = -1
This, should set the two parts of f_Hash to the appropriate values affecting the BITS not the "typed value" and being a 32-bit unsigned integer, converting -1 to a UShort (16 bit unsiged) should equate to 65535, shift left 16 and thus in the end the value of f_Hash after setting the High Word to -1 and the Low Word to -1 should be:
4,294,967,295
So, why won't it let me BITWISE manipulate these items. This is fundamental to what a computer is, and i'm quite tired of the supposed "high level languages" preventing me from manipulating them at the most basic level. Perhaps i'm using the wrong types to achieve this, but I don't quite see why I should need to use a 64 bit to retain what I can use a 32 bit to do.
*shrug*
Tis just frustrating, because C, C++, Pascal, even Fortran can do this, though Fortran might not be up to the 32 bit technology *chuckle*
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner