Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 7th Jun 2013 08:54
I love Hex, it's awesome!



Much love to IanM for is awesome commands.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 7th Jun 2013 14:50 Edited at: 7th Jun 2013 14:53
Made this just out of boredom to prove it can indeed be done using just the standard part of DBP as well



Unfortunately it can not yield double integer values since the bitwise operations do not support those.
Actually it could, if you were to add the partial values (which will always be integers in the range 0..15) to value (which could then indeed be a double integer) instead of OR:ing them together.

I have no doubt IanM's plugin version is more efficient however


"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 8th Jun 2013 09:18 Edited at: 8th Jun 2013 09:21
I should mention that my latest code uses DWORD and not Integer or Double Integer.

I was playing around with a HEX, Binary & Decimal calculator, and I realised that DWORD matches Hex perfectly.

Quote: "
DWORD Range : 0 to 4,294,967,295
HEX Range (specifically for ARGB()): 00000000 to FFFFFFFF
"


So no need for the overly large Double Integer, unless I'm missing or forgetting something?

OH! And I must ask, what are the bitwise operators limited too? I was about to use a bunch of them for matching values together.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Jun 2013 13:33
DWORDs and integers can be cast to each other with no problems in DBP.
for example

The DWORD datatype is simply an unsigned 32-bit integer.
A double integer is a signed 64-bit integer, but they aren't very well supported in DBP. As can be seen in your quote a standard 32-bit value can be written in hexadecimal form, where it ranges from 0 to ffffffff. A 64-bit value would be 0 - ffffffffffffffff.
In DBP, no, you won't need the double integers except in very special cases. The main reason for this is that they are automatically truncated to 32-bit values by most of the built-in functions anyway. The same goes for the double float.

Quote: "OH! And I must ask, what are the bitwise operators limited too? I was about to use a bunch of them for matching values together."

Nothing, really; all data is stored as bits (which, as the name suggests is what these operators operate on), just interpreted differently. But in DBP it seems they can only be used on integers and DWORDs (the same as the built-in dynamic memory functionality).

With some tricks you can convert hexadecimal values to floats as well by the way, and bytes and WORDs are just shorter unsigned integers so that should be no problem.


"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 11th Jun 2013 23:12
Thanks for your advice Rudolpho. Happy coding!

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia

Login to post a reply

Server time is: 2026-07-07 09:29:11
Your offset time is: 2026-07-07 09:29:11