Options

[Programming] Initial commit

13468920

Posts

  • Options
    DisruptedCapitalistDisruptedCapitalist I swear! Registered User regular
    I'm trying to help my daughter with her Python homework, but the only pc I have available right now is using ChromeOS which doesn't seem to be officially supported by Python. Is there any IDE you'd all recommend that can work on Chrome?

    "Simple, real stupidity beats artificial intelligence every time." -Mustrum Ridcully in Terry Pratchett's Hogfather p. 142 (HarperPrism 1996)
  • Options
    BullheadBullhead Registered User regular
    Yeah I have a logitech headset, and teams will just randomly close the meeting I am in when I try to mute/unmute myself via it. Teams is a dumpster fire.

    96058.png?1619393207
  • Options
    LD50LD50 Registered User regular
    I'm trying to help my daughter with her Python homework, but the only pc I have available right now is using ChromeOS which doesn't seem to be officially supported by Python. Is there any IDE you'd all recommend that can work on Chrome?

    Replit might work:
    https://replit.com/new/python3

  • Options
    OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    My experience has been that teams interactions with anything on your headset beyond the volume are a crapshoot likely to fail. I don’t know if that’s a driver problem or a teams problem, but it’s irritating.

    Stop trying to use your headset for muting, use the hot keys instead.

    The amount of voice lag is incredibly obnoxious too if anybody else on the call is in the same room and using a different microphone and speakers

  • Options
    BullheadBullhead Registered User regular
    Orca wrote: »
    My experience has been that teams interactions with anything on your headset beyond the volume are a crapshoot likely to fail. I don’t know if that’s a driver problem or a teams problem, but it’s irritating.

    Stop trying to use your headset for muting, use the hot keys instead.

    The amount of voice lag is incredibly obnoxious too if anybody else on the call is in the same room and using a different microphone and speakers

    I mean, the headset mute/unmute feature works fine with all other calling software I interact with - only teams shits the bed.

    96058.png?1619393207
  • Options
    MadpoetMadpoet Registered User regular
    Wait, are "microphone issues" something other than a euphemism for "I forgot there was a meeting, panicked, and now have a thin fold of skin stuck in my zipper"?

  • Options
    jothkijothki Registered User regular
    I'm thinking I ought to become proficient in Javascript. Any advice on the best way to go about doing that, given that I'm already fluent in other C-like languages?

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    jothki wrote: »
    I'm thinking I ought to become proficient in Javascript. Any advice on the best way to go about doing that, given that I'm already fluent in other C-like languages?

    Just make a weekend experiment project and toss it onto GitHub, you'll get plenty of recruiters calling you an experienced javascript developer.

    Or maybe that's just me?

  • Options
    jothkijothki Registered User regular
    Echo wrote: »
    jothki wrote: »
    I'm thinking I ought to become proficient in Javascript. Any advice on the best way to go about doing that, given that I'm already fluent in other C-like languages?

    Just make a weekend experiment project and toss it onto GitHub, you'll get plenty of recruiters calling you an experienced javascript developer.

    Or maybe that's just me?

    Being able to make a weekend experiment project is my end goal here.

  • Options
    djmitchelladjmitchella Registered User regular
    Today I learned that Postman will let me paste URLs in with a trailing newline:
    4f029pow7f0n.png
    It is _very_ faint about showing it, though, so I spent a pretty confused half an hour trying to work out why I was getting 404s in postman, but when I copy-pasted the URL from Postman into a browser, it worked just fine. (because I wasn't selecting the newline, just the URL, because I hadn't realised the newline was there)

    Today I also learned that the postman console is very useful and I should have it expanded all the time, because
    hvgdtd8w3m7y.png
    is much more obvious about what's going on

  • Options
    TelMarineTelMarine Registered User regular
    Today I learned that Postman will let me paste URLs in with a trailing newline:
    4f029pow7f0n.png
    It is _very_ faint about showing it, though, so I spent a pretty confused half an hour trying to work out why I was getting 404s in postman, but when I copy-pasted the URL from Postman into a browser, it worked just fine. (because I wasn't selecting the newline, just the URL, because I hadn't realised the newline was there)

    Today I also learned that the postman console is very useful and I should have it expanded all the time, because
    hvgdtd8w3m7y.png
    is much more obvious about what's going on

    I'm usually pasting into Sublime Text or Notepad because of weirdness copying/pasting. Paste into a basic text editor that strips everything, then copy again. Usually works well.

    3ds: 4983-4935-4575
  • Options
    LD50LD50 Registered User regular
    Today I present to you a story. The story is fictional, but founded in truth. Names have been altered to protect the guilty.

    Part 1: Reinventing The Wheel, But Like, Biblically.

    You hold an image of a database in your mind, and pull it from the In-Between. Except what you find in your hands is not a database, but a programming language. A programming language with a good built-in hash table type and language designers that had a real big hardon for shoving program code into hash tables.
    Instead of using a dedicated 'query language', a 'query' will be a program that's stored in the database that you retrieve manually (or with another 'query') and evaluate on demand! It's beautiful in it's symmetry.
    You call this database "Foundation".

    Shortly after manifesting Foundation, you begin to see a critical flaw: Having everything be an entry in a hash table makes Foundation fairly bad at being a database. So you imbue it with structure. You crystalize your favorite access patterns out of the aether, shape them with the selfsame language of Foundation, and name them "Schema". You store these patterns away in the almighty hash table, just as the Progenitors willed.
    hash table go brrrrr
    Schema becomes your foremost armament in the eternal battle against Chaos, but you realize that while Schema can save you, it cannot save Foundation. Schema can only protect Foundation from those who wield it, and there are sorcerers who forsake Schema and stain Foundation with their darkness.

    In your final effort to enforce order on the universe, you erect massive walls surrounding Foundation. A lattice of new Schema that enforce how and when programs can be loaded or ran from Foundation, along with a set of Schema-built gates; the only way in or out.

    Part 2: Walls Cannot Protect You From The Enemy Within

    Happy with the order your fortifications have imposed, you begin to work. You encode Functions of aether; realized ideas in whole cloth. Entire applications written in the language of Foundation. Indexed, stored, and recalled by Schema, and executed by Foundation itself, and you are proud.

    As you craft your masterpiece, you find yourself stifled by the rigidity of Schema. You see patterns and shapes that Schema cannot bend to fit. So you search. You search Foundation for a way to bend it to your will, and as you do you stumble upon a loophole. Schema can enforce order at Foundation's gates, but there are no protections to stop a Function from violating Schema if the Function itself does the heavy lifting of modifying Foundation on its own. You quickly begin to forge new Functions that fill in the cracks left by Schema's rigidity.
    Wtf even is this?
    You're proud, and it's easy to distract yourself from the occasional whiffs of rot.

    Part 3: Application Code That Only Runs On A Server Isn't Very Useful To Your Userbase.

    You have built something you believe to be beautiful. Now it is time to share it. You hold in your mind an image of an end-user client application, and you reach back into the In-Between. You smell a hint of sulfur as you pull back from the in-between. You hear a whisper on the wind. 'Thirty Two'. You look at the application you have in your hands and you recoil slightly. You're holding a miserable pile of VB6 application code. You draw the symbol of order over your heart, and you tell yourself "Foundation does all the heavy lifting, this is just a presentation layer, it will be OK". You name it Client and you set it free into the world.

    Part 4: Oh No, We've Ran Out Of Bits!

    Out in the grasslands of your world, there are tribes of Users, huddling in the dark. They sate their appetites with a diet of paper and ink. So wasteful you think to yourself, as you guide your herds of homely Clients into the grasslands.

    The Users hunt your Clients and they feast. With their hunger sated, they begin to look to you for wisdom and salvation. And soon, they come to you. They come to you with requests and needs. Needs you cannot easily meet inside Foundation itself, so you grow new routines in VB6, and you feed them to Client. Your Client is fat and your Users are happy, and all is well.

    For awhile.

    In the morning you hear knocking on your door. The users are here and they are crying "Client has fallen and it can't get up!". You go with them to investigate.

    Client has eaten too much and can no longer stand up on it's own. It has eaten so much that the routines no longer fit into it's 32 bit sized body. This will not be an easy fix.

    Part 5: A pact with the devil.

    You have made mistakes, and you cannot undo what you have done. Client and Foundation are too tightly coupled. You cannot pull routines out of Client because those routines perform now necessary steps, and their paired Functions in Foundation have already modified Foundation's internal structure. All parts are necessary for a functioning system

    You are desperate. You don't know what to do, but you must do something. Your thoughts stray to the agents of Chaos, the sorcerers that Schema was built to protect Foundation from. "They must have experience with this." You think to yourself. You doubt you could bargain with a elder sorcerer, but if you were to capture one of the lesser warlocks you believe you could coerce them into giving up the fundamentals of their dark knowledge. You whisper to yourself: "Just enough to fix this. It will be ok."

    You corner a warlock in a dark alley, and capture them in a recursive trap. They give up their secrets more easily than expected. You hurry back into the deepest room of Foundation and begin your foul labor.

    You're up for three days, and nothing you try works. You finally collapse at your desk in exhaustion, and the answer comes to you in a nightmare. Split the work; distributing things reduces the amount of work you need to do! Add a web browser; a web browser makes everything simpler! Bubble errors up into Client; it's easier to handle them all in one place, even if the pathways that generated them don't actually exist there!

    In a haze you begin carving the symbols you extracted from the warlock into your mind. This time you do not hold in your mind what you seek, and you do not reach into the in-between. Instead, you pray. You pray to Chaos and your mind warps. Your vision changes, and before you is your answer. It may have always been there, but you can see it now. You look upon it, and upon Client, and you retch and swallow back vomit.

    Client has a hole in it's abdomen, where it's gallbladder used to be, and in that hole is a box, stitched into it's flesh and labeled with a trident. The trident is scribbled over with black sharpie and below it is written "IE11".

    At first you think "that's it". That is all that was done, but you notice one of the walls of Foundation has a door that wasn't there before. You cannot stop your curiosity, and you open it and go inside. What you see changes you. The room is filled with endless stalls, each one containing a vivisected Client sustained by Foundation while infernal pumps siphon XHTML from it's veins. You run from the room.

    Part 6: Learning To DrinkCope

    You've accepted that things have gotten out of your control. You do your best, but it is rarely enough. Your sleep is troubled; you've developed a habit of drinking at the end of your night to ease your insomnia.

    You do not understand the creature that now serves your Users; although you've been trying to. Things are Complicated now. It is never clear where something went wrong when something inevitably fails. Is there a problem with Client, or is the XHTML it nurses from foul? Is Client's vivisected zombie partner sick or has Foundation failed to feed it? Has the Schema fractured, or has a malodorous Function rotted away a crossbeam?

    You begin to develop an understanding, a feeling. An instinct for what prayers He will answer to. You add a shim here, a bandage there. You draw spidery glyphs in dark corners and you sprinkle salt and ash across boundaries.

    For awhile, slowly, things improve. They improve in that way where a dying man finds strength before the end.

    This morning you're woken up early to another knock on your door. Another User with another dead client, but this Client came bearing a message:
    Client wrote:
    An error occurred, but no detail is logged.
    Error code: g2ffb8b0e
    
    While the story is fictional, the error text is verbatim. (And I read it as a threat, for indeed, nothing was logged.)

  • Options
    dporowskidporowski Registered User regular
    edited June 2023
    Still better than "Error: Success".

    Edit: Or "Success: Error."

    dporowski on
  • Options
    LuvTheMonkeyLuvTheMonkey High Sierra Serenade Registered User regular
    Terraform is cool.

    Finicky at times! But cool.

    Molten variables hiss and roar. On my mind-forge, I hammer them into the greatsword Epistemology. Many are my foes this night.
    STEAM | GW2: Thalys
  • Options
    AngelHedgieAngelHedgie Registered User regular
    Seen elsewhere:
    Person A: A friend learned COBOL and received a codebase where the last change was done in the 90s...by his mom.

    Person B: That's not how inheritance is supposed to work in programming.

    XBL: Nox Aeternum / PSN: NoxAeternum / NN:NoxAeternum / Steam: noxaeternum
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Terraform is cool.

    Finicky at times! But cool.

    I'm very much adoring it. After starting using it at work for AWS stuff as infra-as-code, I started dabbling with it at home to learn Kubernetes for my little baby homelab cluster on a bunch of Raspberries.

    Some time soon I'm planning to look into writing my own provider for something as a learning experience.

    Providers are basically just binaries (typically written in Go since there's a solid Terraform package for it) that glue together Terraform (using RPC of some flavor) with whatever API you want the provider for.

  • Options
    TelMarineTelMarine Registered User regular
    Echo wrote: »
    Terraform is cool.

    Finicky at times! But cool.

    I'm very much adoring it. After starting using it at work for AWS stuff as infra-as-code, I started dabbling with it at home to learn Kubernetes for my little baby homelab cluster on a bunch of Raspberries.

    Some time soon I'm planning to look into writing my own provider for something as a learning experience.

    Providers are basically just binaries (typically written in Go since there's a solid Terraform package for it) that glue together Terraform (using RPC of some flavor) with whatever API you want the provider for.

    I get you're doing all that to learn/tinker, but couldn't help but think of this

    3ds: 4983-4935-4575
  • Options
    AnteCantelopeAnteCantelope Registered User regular
    I signed up to AWS just to see what it's like, get some experience that might be useful in a future jobhunt. But goddamn it's huge and nothing's easy. I try to use Elastic Beanstalk, but now I need to create an IAM role with the required IAM policies... I clearly messed something up here so I try using CodeDeploy instead. "Enter a service role with CodeDeploy permissions"?

    I think I'm going to need to follow an actual tutorial, not just poke around and figure it out.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Yeah, AWS is definitely very overwhelming when you're starting from scratch.

    Not to bang the Terraform drum intentionally again, but I've found it very helpful to actually see what a working setup looks like -- rather than clicking around and forgetting what you've changed, you have a hopefully working config as code, and you know that what you have in code is the current state.

  • Options
    electricitylikesmeelectricitylikesme Registered User regular
    I signed up to AWS just to see what it's like, get some experience that might be useful in a future jobhunt. But goddamn it's huge and nothing's easy. I try to use Elastic Beanstalk, but now I need to create an IAM role with the required IAM policies... I clearly messed something up here so I try using CodeDeploy instead. "Enter a service role with CodeDeploy permissions"?

    I think I'm going to need to follow an actual tutorial, not just poke around and figure it out.

    Try not to do things in AWS with the GUI. Cloudformation is a quite capable, and will give you a much better way to follow what's going on under the hood.

  • Options
    TelMarineTelMarine Registered User regular
    Echo wrote: »
    Yeah, AWS is definitely very overwhelming when you're starting from scratch.

    Not to bang the Terraform drum intentionally again, but I've found it very helpful to actually see what a working setup looks like -- rather than clicking around and forgetting what you've changed, you have a hopefully working config as code, and you know that what you have in code is the current state.

    I found Terraform is useless unless you already know what the resources you want to provision, do. AWS does have some trainings you can go through that go through the basics so you can learn what a VPC is, subnet is, etc.

    3ds: 4983-4935-4575
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    edited July 2023
    TelMarine wrote: »
    I found Terraform is useless unless you already know what the resources you want to provision, do. AWS does have some trainings you can go through that go through the basics so you can learn what a VPC is, subnet is, etc.

    Yeah, that's basically what I meant. Learn what you need, then stitch it together as code.

    Echo on
  • Options
    schussschuss Registered User regular
    edited July 2023
    I signed up to AWS just to see what it's like, get some experience that might be useful in a future jobhunt. But goddamn it's huge and nothing's easy. I try to use Elastic Beanstalk, but now I need to create an IAM role with the required IAM policies... I clearly messed something up here so I try using CodeDeploy instead. "Enter a service role with CodeDeploy permissions"?

    I think I'm going to need to follow an actual tutorial, not just poke around and figure it out.

    Try not to do things in AWS with the GUI. Cloudformation is a quite capable, and will give you a much better way to follow what's going on under the hood.

    Also, plenty of shops don't allow production console access without break glass type stuff so it's a good habit.

    schuss on
  • Options
    AngelHedgieAngelHedgie Registered User regular
    So, these rejected GitHub achievements had me laughing.

    XBL: Nox Aeternum / PSN: NoxAeternum / NN:NoxAeternum / Steam: noxaeternum
  • Options
    tyrannustyrannus i am not fat Registered User regular
    kafka / event sourcing / postgres confuses the shit outta me and I want to learn more

  • Options
    DisruptedCapitalistDisruptedCapitalist I swear! Registered User regular
    So, these rejected GitHub achievements had me laughing.

    Oh dear, the procrastinator is so me.

    "Simple, real stupidity beats artificial intelligence every time." -Mustrum Ridcully in Terry Pratchett's Hogfather p. 142 (HarperPrism 1996)
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    I'll get to it...

    Ooh shiny new project!

  • Options
    AngelHedgieAngelHedgie Registered User regular
    So, these rejected GitHub achievements had me laughing.

    Oh dear, the procrastinator is so me.

    Arborist is the one that I'm guilty of on GitHub at work.

    XBL: Nox Aeternum / PSN: NoxAeternum / NN:NoxAeternum / Steam: noxaeternum
  • Options
    DisruptedCapitalistDisruptedCapitalist I swear! Registered User regular
    So, these rejected GitHub achievements had me laughing.

    Oh dear, the procrastinator is so me.

    Arborist is the one that I'm guilty of on GitHub at work.

    That's just sensible!

    "Simple, real stupidity beats artificial intelligence every time." -Mustrum Ridcully in Terry Pratchett's Hogfather p. 142 (HarperPrism 1996)
  • Options
    admanbadmanb unionize your workplace Seattle, WARegistered User regular
    I like the idea of 2 FU because it would just be a badge on your account that says “hack me.”

  • Options
    EtheaEthea Registered User regular
    edited July 2023
    Every Arborist person/project drives me slight crazy. Even better when i need to clone a branch and i need to pick through branches with names like “feature”, “feature_v2”, “feature-v2”.

    I would have “its bad luck”, “patient skeleton”, “monkey wrench”, and “it works on my machine” ( lots of user errors with cmake ). I dodge the 1000 open issues since a bot owns all our repos.

    Ethea on
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    admanb wrote: »
    I like the idea of 2 FU because it would just be a badge on your account that says “hack me.”

    I solve that by having nothing worth hacking and no repos anyone else uses

  • Options
    djmitchelladjmitchella Registered User regular
    edited July 2023
    I just took a quick look at threads.net to see what's there; turns out it's a spinning set of dots and a QR code. Which I guess isn't too surprising given it's meant to only be an app right now.

    What did surprise me a bit was that it loads about 16 JS files to make those dots (presumably just generic facebook boilerplate and somewhere buried in them all is the actual 3d math part), which are for some reason being served up by PHP?

    (edit: ah, here's an explanation on SO, from the original author of rsrc.php)

    Clicking into one of them to see if I could work what the heck it's doing, they're all obfuscated to bits, except for when this sort of thing is just sitting there -- I suppose at least it's clear about what I should(not) be doing with this:

    6fej8caftdhb.png

    djmitchella on
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    edited July 2023
    I'm dabbling with an Arduino experiment where I need to address four individual magnet coils for a stepper motor. I've never had to do much of anything with flipping individual bits before, so this is a very fun learning experiment.

    There is a stepper driver library for Arduino, but where's the fun in that? Because the Arduino IDE sucks and has a long feedback cycle to test stuff, I'm writing a prototype in Go first.

    So let's define some stuff.
    // Magnet coil addresses
    const (
    	magnet1 = 0x01
    	magnet2 = 0x02
    	magnet3 = 0x04
    	magnet4 = 0x08
    )
    
    // Used to be able to iterate over magnets
    var magnets = []int{magnet1, magnet2, magnet3, magnet4}
    
    var waveDrive = []int{
    	magnet1,
    	magnet2,
    	magnet3,
    	magnet4,
    }
    

    A wave drive is just running each magnet in sequence, and then you start over.

    Let's try that:
    step 0: magnet 0 enabled => true
    step 0: magnet 1 enabled => false
    step 0: magnet 2 enabled => false
    step 0: magnet 3 enabled => false
    --- step 0 done
    step 1: magnet 0 enabled => false
    step 1: magnet 1 enabled => true
    step 1: magnet 2 enabled => false
    step 1: magnet 3 enabled => false
    --- step 1 done
    step 2: magnet 0 enabled => false
    step 2: magnet 1 enabled => false
    step 2: magnet 2 enabled => true
    step 2: magnet 3 enabled => false
    --- step 2 done
    step 3: magnet 0 enabled => false
    step 3: magnet 1 enabled => false
    step 3: magnet 2 enabled => false
    step 3: magnet 3 enabled => true
    --- step 3 done
    

    Success!

    ...but then I ran into problems where I want to define full steps and half steps, which requires running a combination of magnets, because I suck at bitwise ops. To the google machine!

    Echo on
  • Options
    OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    Echo wrote: »
    I'm dabbling with an Arduino experiment where I need to address four individual magnet coils for a stepper motor. I've never had to do much of anything with flipping individual bits before, so this is a very fun learning experiment.

    There is a stepper driver library for Arduino, but where's the fun in that? Because the Arduino IDE sucks and has a long feedback cycle to test stuff, I'm writing a prototype in Go first.

    ...

    Success!

    ...but then I ran into problems where I want to define full steps and half steps, which requires running a combination of magnets, because I suck at bitwise ops. To the google machine!

    If you're messing in embedded, now is the PERFECT time to get comfortable with bit twiddling.

    Bit twiddling is how you talk to the hardware!

    Do you have anything else running on the Arduino? What do you have the stepper attached to?

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Orca wrote: »
    Do you have anything else running on the Arduino? What do you have the stepper attached to?

    Nothing else running on it. I got an idea to make a small display turntable to take neat 360s of miniatures, and I'll be the first to admit that a stepper motor is way overkill for this, but it's a fun experiment.

    I scrounged up a breadboard power supply that gives 5V to the stepper driver and 3.3V to the Arduino (it can take 5V no problems though, but why waste it), and then there'll be four wires from the Arduino to the stepper driver to do the spinny thing.

    After some RTFM I got it working properly now:
    package main
    
    import "fmt"
    
    // Magnet coil addresses
    const (
    	magnet1 = 0x01
    	magnet2 = 0x02
    	magnet3 = 0x04
    	magnet4 = 0x08
    )
    
    // Used to be able to iterate over magnets
    var magnets = []int{magnet1, magnet2, magnet3, magnet4}
    
    var waveDrive = []int{
    	magnet1,
    	magnet2,
    	magnet3,
    	magnet4,
    }
    
    var fullStep = []int{
    	magnet1 | magnet2,
    	magnet2 | magnet3,
    	magnet3 | magnet4,
    	magnet4 | magnet1,
    }
    
    var halfStep = []int{
    	magnet1,
    	magnet1 | magnet2,
    	magnet2,
    	magnet2 | magnet3,
    	magnet3,
    	magnet3 | magnet4,
    	magnet4,
    	magnet4 | magnet1,
    }
    
    func main() {
    	// Outer loop: loop over steps
    	for step, mask := range waveDrive {
    		// Inner loop: loop over each magnet
    		for magnet := 0; magnet < len(magnets); magnet++ {
    			fmt.Printf("step %v: magnet %v enabled => %v\n", step, magnet, magnetState(magnets[magnet], mask))
    		}
    		fmt.Printf("--- step %v done\n", step)
    	}
    }
    
    // check whether a given magnet should be on or off
    func magnetState(magnet, mask int) bool {
    	return magnet&mask != 0
    }
    

  • Options
    OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    awwwwww yeah. Stepper motor is overkill for that application, but now you don't need to worry about missed steps, startup conditions, and other such nonsense.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Yeah, this is just as much a learning experience as a practical project. Otherwise I'd just have gone with some simple DC motor, maybe with a potentiometer as speed control.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Wow, this was some subtle shadowing thing where I just had a hunch that turned out to be it.

    Doesn't work as expected:
    bool magnetEnabled(int magnet, int mask) {
      return magnet & mask != 0;
    }
    

    Works:
    bool magnetEnabled(int magnet, int mask) {
      return (magnet & mask) != 0;
    }
    

    Magnets embedded systems with magnets, how do they work!

  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Bitwise operators are lower than equality so the compiler sees (magnet & (mask != 0)) != 0

    You would have been fine if you'd used the implicit test by leaving out the !=

Sign In or Register to comment.