English Amiga Board [blitz] need a small translation from c
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 27 October 2019, 20:26 #1 peceha Registered User   Join Date: Dec 2017 Location: Poland Age: 43 Posts: 208 [blitz] need a small translation from c Hi, Code: SerReq->io_SerFlags &= ~SERF_PARTY_ON SerReq->io_SerFlags |= SERF_XDISABLED is it like: Code: *sereq\io_SerFlags = *sereq\io_SerFlags & NOT #SERF_PARTY_ON *sereq\io_SerFlags = *sereq\io_SerFlags | #SERF_XDISABLED ? Thanks
 27 October 2019, 22:15 #2 thomas Registered User   Join Date: Jan 2002 Location: Germany Posts: 5,873 No, these are bit-wise operations, not boolean. x &= ~y clears every bit in x that is set in y x |= y sets every bit in x that is set in y.
 27 October 2019, 22:17 #3 Daedalus Registered User   Join Date: Jun 2009 Location: Dublin, then Glasgow Posts: 4,345 That looks correct to me anyway, but I haven't tested it... Edit: Hmmm, maybe my brain's tired now, but thomas' post has me thinking. I still can't see that it's any different - & and | operate in a bitwise fashion in Blitz.
 27 October 2019, 22:25 #4 thomas Registered User   Join Date: Jan 2002 Location: Germany Posts: 5,873 Is NOT bitwise, too? Then what would be the boolean "not" operator in Blitz? In C ^ is the boolean not, ~ is bitwise.
 27 October 2019, 22:32 #5 Daedalus Registered User   Join Date: Jun 2009 Location: Dublin, then Glasgow Posts: 4,345 yes, NOT is bitwise too. It works in boolean expressions because true is accepted to be any non-zero value, but is always returned as -1. So a bitwise NOT of -1 will equate to 0 / false. So: Code: If NOT x = y Then NPrint "Not equal" Works because x = y is evaluated as -1 or 0, as does Code: NPrint Bin\$(NOT %10000000)
28 October 2019, 09:48   #6
thomas
Registered User

Join Date: Jan 2002
Location: Germany
Posts: 5,873
Quote:
 Originally Posted by Daedalus NOT is bitwise too. It works in boolean expressions because true is accepted to be any non-zero value
This is a contradiction in itself. If any non-zero value is true, then 2 is true, too. If NOT is bitwise, then NOT 2 is -3 which is still true. So NOT does not work in boolean expressions. It only works if TRUE (a.k.a. -1) has been returned by a comparison.

28 October 2019, 13:13   #7
Daedalus
Registered User

Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 4,345
When you put it like that, indeed, but my point was made in the rest of the sentence after that:
Quote:
 , but is always returned as -1
Boolean expressions are always returned to the evaluation as true or false. If the terms you NOT are just boolean, then it's a boolean operation. If you try to NOT anything non-boolean, then it's bitwise. Context is key.

28 October 2019, 14:48   #8
Hedeon
PPC Hacker

Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,092
Quote:
 Originally Posted by thomas In C ^ is the boolean not, ~ is bitwise.
What is ! and what is 'exclusive or' bitwise? I am still learning but I thought ^ was something else?

28 October 2019, 15:35   #9
hooverphonique
ex. demoscener "Bigmama"

Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,001
Quote:
 Originally Posted by Hedeon What is ! and what is 'exclusive or' bitwise? I am still learning but I thought ^ was something else?
in C, ! is logical not, ^ is bitwise xor.

 28 October 2019, 17:41 #10 Hedeon PPC Hacker   Join Date: Mar 2012 Location: Leiden / The Netherlands Posts: 1,092 So NOT could be bitwise, boolean and logical? ok.
28 October 2019, 18:27   #11
hooverphonique
ex. demoscener "Bigmama"

Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,001
Quote:
 Originally Posted by Hedeon So NOT could be bitwise, boolean and logical? ok.
What is referred to as 'boolean' above is the equivalent of my 'logical', I think. Boolean logic applies to both bitwise and logical operators, so it may be a bit misleading calling one of them 'boolean'.

 28 October 2019, 18:48 #12 Daedalus Registered User   Join Date: Jun 2009 Location: Dublin, then Glasgow Posts: 4,345 Yeah, the names can be a little confusing. Boolean is a *type* of logic, where you can only have two values, true or false, 1 or 0. A boolean variable is one which is essentially 1 bit. In computing terms, "logical" is usually used to describe operations where each entire term is taken as boolean, so each value can be either true or false, regardless of what arrangement of bits they actually contain. "Bitwise" is used to refer to operations that focus on the individual bits of a value, rather than what it represents overall. C has explicit operators that differentiate the two, ! is (boolean) logical NOT and ~ is bitwise NOT. Blitz doesn't really have that same concept of boolean values, and so internally represents true as -1 and false as 0. So something like Code: NPrint 5>3 will produce -1 as the output, because 5 is greater than 3. The reason it does this is that -1 (true) is represented in binary as all ones (%11111111), and 0 (false) is represented as all zeroes (%00000000). Thus, doing a bitwise NOT (flipping every bit in the value) swaps true to false and false to true. So Code: NPrint NOT 5>3 will output 0. This works for all Blitz operations that are boolean in nature, however it does mean that Blitz can't check for a zero value by doing e.g. NOT filehandle as is common in C (!filehandle). Instead, filehandle <> 0 is used.

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Similar Threads Thread Thread Starter Forum Replies Last Post JPQ Coders. Blitz Basic 0 08 October 2019 10:40 saimon69 Coders. Blitz Basic 104 29 November 2016 21:45 formater support.WinUAE 0 07 July 2013 23:21 laser support.Other 0 02 September 2008 20:32 Carlos Ace support.WinUAE 1 14 July 2005 03:12

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE         project.AmigaLive     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.EAB File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     Kinky Amiga Stuff     Collections     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic     Coders. Contest         Coders. Entries Creation     Graphics         Graphics. Work In Progress         Graphics. Finished Work         Graphics. Tutorials     Music         Music. Work In Progress         Music. Finished Work         Music. Tutorials Off Topic     OT - General     OT - Entertainment     OT - Sports     OT - Technical     OT - Gaming

All times are GMT +2. The time now is 16:04.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top