Feed aggregator
Brazil's Grid Caps Power From Wind and Solar, Threatening Renewable Projects
Read more of this story at Slashdot.
Hydrogels Can Learn To Play Pong
Read more of this story at Slashdot.
Instagram Is Adding a Myspace-Like 'Song On Profile' Feature
Read more of this story at Slashdot.
Google Play Will No Longer Pay To Discover Vulnerabilities In Popular Android Apps
Read more of this story at Slashdot.
Crypto 'Pig Butchering' Scam Wrecks Kansas Bank, Sends Ex-CEO To Prison For 24 Years
Read more of this story at Slashdot.
Bug in Apple Devices Crashes UI With Four-Character Input
Read more of this story at Slashdot.
Humans To Push Further Into Wildlife Habitats Across More Than 50% of Land by 2070, Study Says
Read more of this story at Slashdot.
Apple Will Allow EU Users To Delete Safari, Messages and App Store Apps
Read more of this story at Slashdot.
Microsoft Will Try the Data-Scraping Windows Recall Feature Again in October
Read more of this story at Slashdot.
AGI is On Clients' Radar But Far From Reality, Says Gartner
Read more of this story at Slashdot.
Microsoft Engineers' Pay Data Leaked, Reveals Compensation Details
Read more of this story at Slashdot.
Peloton To Start Charging Subscribers With Used Equipment $95 Activation Fee
Read more of this story at Slashdot.
Apple is Still Standing in the Way of Epic's App Store
Read more of this story at Slashdot.
Bezos' Blue Origin Suffers Fiery Setback Building New Rocket
Read more of this story at Slashdot.
Lionsgate Pulls 'Megalopolis' Trailer Offline Due To Made-Up Critic Quotes
Read more of this story at Slashdot.
Ryzen 9 9950X Performs 16% Faster On Intel-Optimized Linux Distro
Read more of this story at Slashdot.
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.