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.

Newcomers AppGameKit Corner / [SOLVED] Meaning of the "%" in front of number

Author
Message
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado
Posted: 27th Mar 2020 12:39
What does this mean %11? as in the function call below:
InitialiseScreen(1024,768,"Some Name",0xF2D8AA, %11)[size=large]
Cheers!

The author of this post has marked a post as an answer.

Go to answer

Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 27th Mar 2020 12:50 Edited at: 27th Mar 2020 12:54
This post has been marked by the post author as the answer.
In AppGameKit, It means you are specifying a binary number (specifying the number base)

so %11 is the same as just putting in 3 , or even 0x03

0x is for hexadecimal values
% is for binary values
0c is for octal
other numbers are considered decimal (base 10)

https://www.appgamekit.com/documentation/principles/7_bases.htm
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 27th Mar 2020 13:34
% is for Binary Values... I've always been curious why TGC didn't use 0b as they use 0x and 0c for the other formats., but they've always done odd things.
Anyway, as Bengismo says there's no real difference between putting say

ValueBin = %10101011 // Base 2
ValueHex = 0xAB // Base 16
ValueOct = 0x253 // Base 8
ValueDec = 171 // Base 10

Personally I find it useful to use the Number Base that reads the best for what I'm doing.
So... if I'm using Binary Flags, then I'll use % Binary Numbers... as then you can see exactly which Bits you're flagging
For Colours I tend to use Hex, as 0x00 to 0xFF (0 to 255) is a little easier to remember... especially as the 50% is 0x8
I've never used Oct ... not sure of a use case for it.

Then Decimal is just easier to do general Mathematics with.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 27th Mar 2020 13:57 Edited at: 27th Mar 2020 13:58
Quote: "I've always been curious why TGC didn't use 0b as they use 0x and 0c for the other formats., but they've always done odd things."


Amen!! In so many other languages its 0b for binary and conforms to the 0x, 0c logic of specifying a number base.... And % is normally a modulus command at least in 3 other languages so to use it to signify binary number base in AppGameKit baffled me too.

Yep, when using binary flags it can be easier to specify, Hex is useful too but I must admit octal is one I have never used either.
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado
Posted: 27th Mar 2020 14:55
Thanks guys! Now that you say it it makes sense. I should have deciphered it from the rest of the call .
Cheers!

Login to post a reply

Server time is: 2024-04-23 21:18:29
Your offset time is: 2024-04-23 21:18:29