Tax rises are coming... and if air travellers are sacrificed to pay even more, it will be a disaster for Britain, says former BA boss
Will 'deluded and loathed' £300k-a-year BBC deputy who is 'staunch defender of doctored Donald Trump footage' be next Beeb boss to be swept away?
Police seek well-dressed couple after family 'assaulted and racially abused outside central-London Tube station'
Inside the madcap world of floundering Ferrari: How relentless backstabbing behind the scenes is sabotaging the Scuderia - with their chairman's hypocritical barbs at Lewis Hamilton the latest self-inflicted wound
Trans woman, 28, stalked top surgeon who carried out her gender reassignment surgery - before threatening to 'batter' her
Revealed: The cold fury that erupted as BBC board turned on news boss. But will hurricane Deborah take her revenge?
Homeowner fights off armed intruder in his undies - after making one small mistake we're all guilty of
Warren Buffett's final farewell: the billionaire who once fingerprinted nuns says he's 'going quiet'
LEO MCKINSTRY: Though Parkinson's is laying waste to my body, I refuse to stop working. And I feel only disdain for all those who say their mental health comes first
Man accused of arson, GBH and possession of class B drug named
Young drivers falling for this online scam are losing £2,000 on average to fraudsters
China's CO2 Emissions Have Been Flat Or Falling For Past 18 Months, Analysis Finds
Read more of this story at Slashdot.
Late Queen 'feared William would become a celebrity monarch' as her grandson's 'rigidity' left her 'frustrated'
CodeSOD: Losing a Digit
Alicia recently moved to a new country and took a job with a small company willing to pay well and help with relocation costs. Overall, the code base was pretty solid. Despite the overall strong code base, one recurring complaint was that running the test suite was painfully long.
While Alicia doesn't specify what the core business is, but says: "in this company's core business, random numbers were the base of everything."
As such, they did take generating random numbers fairly seriously, and mostly used strong tools for doing that. However, whoever wrote their test suite was maybe a bit less concerned, and wrote this function:
public static Long generateRandomNumberOf(int length) { while (true) { long numb = (long)(Math.random() * 100000000 * 1000000); // had to use this as int's are to small for a 13 digit number. if (String.valueOf(numb).length() == length) return numb; } }They want many digits of random number. So they generate a random floating point, and then multiply it a few times to get a large number. If the length of the resulting number, in characters, is the desired length, we return it. Otherwise, we try again.
The joy here, of course, is that this function is never guaranteed to exit. In fact, if you request more than 15 digits, it definitely won't exit. In practice, most of the time, the function is able to hit the target length in a relative handful of iterations, but there's no guarantee for that.
Alicia was tracking down a bug in a test which called this function. So she went ahead and fixed this function so that it use a sane way to generate the appropriate amount of entropy that actually guaranteed a result. She included that change in her pull request, nobody had any comments, and it got merged in.
The unit tests aren't vastly faster than they were, but they are faster. Who knows what other surprises the test suite has in store?
Why comedian Marcus Brigstocke spent 'silly money' buying the same motorhome TWICE
Intel CTO and AI boss quits to join OpenAI after just six months in the job
Sachin Katti, the exec Intel promoted to chief technology and AI officer in April, will leave the x86 giant to join OpenAI after just six months in the job.…