in , ,

itsokayguystheyfixedIt

itsokayguystheyfixedIt | code-memes, git-memes, github-memes, ios-memes, string-memes, if statement-memes, authentication-memes, fix-memes, search-memes, release-memes, c#-memes, source code-memes, private-memes, binary-memes | ProgrammerHumor.io
code-memes, git-memes, github-memes, ios-memes, string-memes, if statement-memes, authentication-memes, fix-memes, search-memes, release-memes, c#-memes, source code-memes, private-memes, binary-memes | ProgrammerHumor.io

Content

Jeroen Frijters JeroenFriters 1d The Dutch government was forced to release the source code of their DigiD digital authentication iOS app. It is written in C. github.comMinBZKwoo-bes… private static string GetPercentageRounds (double percentage) if percentage return "0000000000"; if percentage 0.0 88 percentage 0.1 000000000"; coercentage 1 percentage 0.2) 00000000"; percentas percentage 0.3) 0000": Goercented percentage 0.4) 00" (bercentag ntage 0.5) (bercentag 0.6) percentage 0.7) if (percentage return nancentage percentage 0.8) 00000"; ?? pencentage 0.9) return return la 1.3M O 308 171.196 0 6.678 tyrannoSaurav TyrannoSaurav Replying to JeroenFrijters Ahh I see the problem is that there are too many if statements. Here’s a solution implementing binary search in O(log n) private static string GetPercentageRounds double percentage) if (percentage 66 percentage 0.5) f if (percentage 0.2) if (percentage 0.1) if (percentage return return 0000"; 0000"; return c0000": if (percentage 0.4) S if (percentage 0.3) return 000000"; return 00000": return if (percentage 0.5 86 percentage 0.9) if (percentage 0.7) if narcentare return return if (perceptage return return