Computer
Second Human To Receive Neuralink Brain Chip Uses It To Play Counter-Strike 2
Read more of this story at Slashdot.
CodeSOD: Maximally Zero
Today's anonymous submitter found some Java code which finds the largest value in a quartet of floats. Now, the code is quite old, so it actually predates varargs in Java. That doesn't excuse any of what you're about to see.
public float CalculateMaximumValue(float a, float b, float c, float d) { int i = 0; float[] arr = new float[] { 0, 0, 0, 0 }; float gtval = 0; for (i = 0; i < 4; i++) { arr[i] = 0; } arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; gtval = arr[0]; for (i = 0; i < 4; i++) { if (arr[i] > gtval) { gtval = arr[i]; } } return gtval; }The best thing I can say about this is that they didn't use some tortured expansion of every possible comparison:
if (a > b && a > c && a > d) return a; if (b > a && b > c && b > d) return b; …Honestly, that would be awful, but I'd prefer it. This just makes my eyes sting when I look at it.
But let's trace through it, because each step is dumb.
We start by creating an empty array, where every value is initialized to zero. This isn't necessary, as that's what Java does by default. But then, we loop across the array to set things to zero one more time, just to be sure.
Once we're convinced every value is definitely zero, we replace those zeroes with the real values. Then we can loop across the array and find the largest value with straightforward comparisons.
This code is, in some ways, the worst kind of code. It's bad, but not so bad as it's ever going to cause real, serious problems. No one is going to see any bugs or inefficiencies coming from this method. It's just an ugly mess that's going to sit there in that codebase until the entire thing gets junked, someday. It's just an irritant that never rises to the level of frustration which drives action.
[Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!Top US Oilfield Firm Halliburton Hit By Cyberattack, Source Says
Read more of this story at Slashdot.
110K Domains Targeted in 'Sophisticated' AWS Cloud Extortion Campaign
Read more of this story at Slashdot.
Sonos CEO Says the Old App Can't Be Rereleased
Read more of this story at Slashdot.
App Store VP Departs As Apple Prepares Organizational Changes
Read more of this story at Slashdot.
Google Agrees To $250 Million Deal To Fund California Newsrooms, AI
Read more of this story at Slashdot.
IT Tycoon Mike Lynch, Daughter Hannah Found Dead
Read more of this story at Slashdot.
Microsoft Copilot Studio Exploit Leaks Sensitive Cloud Data
Read more of this story at Slashdot.
Rotten Tomatoes Introduces a New Audience Rating For People Who Actually Bought a Ticket
Read more of this story at Slashdot.
Intel Discontinues High-Speed, Open-Source H.265/HEVC Encoder Project
Read more of this story at Slashdot.
Google Can't Defend Shady Chrome Data Hoarding As 'Browser Agnostic,' Court Says
Read more of this story at Slashdot.
Microplastics Are Infiltrating Brain Tissue, Studies Show
Read more of this story at Slashdot.
Linux Market Share Hits Record High
Read more of this story at Slashdot.
South Africa's Telco Industry Calls For Tech Firms To Help Fund Infrastructure
Read more of this story at Slashdot.
CrowdStrike Unhappy With 'Shady Commentary' From Competitors After Outage
Read more of this story at Slashdot.
US Feds Are Tapping a Half-Billion Encrypted Messaging Goldmine
Read more of this story at Slashdot.
Slack AI Can Be Tricked Into Leaking Data From Private Channels
Read more of this story at Slashdot.
Microsoft's White Xbox Series X and 2TB Special-edition Model Launching in October
Read more of this story at Slashdot.
Missing Scissors Cause 36 Flight Cancellations In Japan
Read more of this story at Slashdot.