|
Phobeste posted:Well you could also do assert(bitmask & (1<<cert_bp) or whatever. I thought that was the point, it's kind of an overly-verbose way to get the point across. Yeah, we don't know if certMask is used again. It's definitely not the same as m_certMask, though. Being overly verbose usually isn't considered to be "clever".
|
# ? May 25, 2014 03:41 |
|
|
# ? May 21, 2024 06:23 |
|
Subjunctive posted:Why would you do it differently for those two cases? Generally I favour consistency, so this is certainly a reasonable position to take. It's just that it's easy to recognise small powers of two and harder to recognise larger ones. Since small powers of two are easily recognised, so the song and dance about obtaining the value 2 seen in the original code snippet seems excessive. The transition point between powers of two that are "small" and "big" would be subjective. (For example, I would be able to identify 8192 as a power of 2, but I wouldn't assume that another programmer would do so as well. It would take me a moment's thought to identify it more specifically as 2 to the power 13.) quote:Using a hex literal isn't any clearer, IMO, but it wouldn't be horrible and I wouldn't bounce something at code review for it if that was the pattern. But do you really know that 0x8000000 is bit 27 as easily? (Count those zeroes!) It is clear that it is a power of two, however, and so the nature of the operation being carried out is clear. I agree that if you need to know at a glance which bit it is it's a bit of a hassle.
|
# ? May 25, 2014 11:25 |
|
The correct way to test a bit in C++ is obviously:C++ code:
|
# ? May 25, 2014 12:02 |
|
Zombywuf posted:The correct way to test a bit in C++ is obviously: why not just use value??
|
# ? May 25, 2014 18:15 |
|
Zombywuf posted:The correct way to test a bit in C++ is obviously: Is the 8 correct?
|
# ? May 25, 2014 18:27 |
|
OddObserver posted:Is the 8 correct? you'd want to use CHAR_BIT, obviously
|
# ? May 25, 2014 18:35 |
|
OddObserver posted:Is the 8 correct? you'd want to use std::numeric_limits<Integer>::digits, obviously
|
# ? May 25, 2014 18:51 |
|
Hammerite posted:(For example, I would be able to identify 8192 as a power of 2, but I wouldn't assume that another programmer would do so as well. It would take me a moment's thought to identify it more specifically as 2 to the power 13.) 1 << 13 is a lot clearer than 8192, imo. Especially if that 13 is derived from variable or some other computation.
|
# ? May 25, 2014 19:07 |
|
Voted Worst Mom posted:1 << 13 is a lot clearer than 8192, imo. Yeah, which is why you use 0x2000. More seriously, I like the kernel macro BIT(n) which does the shift and makes the intent clear.
|
# ? May 25, 2014 19:51 |
|
MutantBlue posted:you'd want to use std::numeric_limits<Integer>::digits, obviously how could i forget digits. so shameful
|
# ? May 25, 2014 22:52 |
|
That int should be HOST_WIDE_INT, too.
|
# ? May 25, 2014 22:59 |
|
Voted Worst Mom posted:That int should be HOST_WIDE_INT, too. No, it most definitely should not be unless you're writing code that's part of GCC.
|
# ? May 26, 2014 00:45 |
|
It isn't used anywhere else. It's a verification check to ensure that we got to this function with the proper value in m_certMask. Also, clIdx is used as an index into a list (of certificates) later. There is no relation between the bits that a cert might have set and its position in the list. Obviously 1 << 8 is the idiomatic way to get 2^8 especially when testing bits, but this wasn't that case.
|
# ? May 27, 2014 17:39 |
|
Saw this and shook my head. Can you spot the problem(s)?code:
|
# ? May 27, 2014 20:23 |
|
Jonah Hex posted:Saw this and shook my head. Can you spot the problem(s)? Most critically, time / freq is done in an integer context, isn't it? - http://stackoverflow.com/questions/6517435/dividing-unsigned-long-long Also, I can figure out how many milliseconds there are in a second without that define, but if you must. And you should probably multiply before dividing if you're gonna do that. ulmont fucked around with this message at 20:47 on May 27, 2014 |
# ? May 27, 2014 20:44 |
|
Jonah Hex posted:Saw this and shook my head. Can you spot the problem(s)? perfcounters measure in ticks, not milliseconds!!!! e: actually reading the code, it looks like that's taken care of Malcolm XML fucked around with this message at 21:50 on May 27, 2014 |
# ? May 27, 2014 21:45 |
Malcolm XML posted:perfcounters measure in ticks, not milliseconds!!!! freq is ticks per second.
|
|
# ? May 27, 2014 21:46 |
|
ulmont posted:Most critically, time / freq is done in an integer context, isn't it? - http://stackoverflow.com/questions/6517435/dividing-unsigned-long-long That was the big one. The other issue is using a high resolution timer then truncating it to milliseconds.
|
# ? May 27, 2014 22:02 |
|
The windows GetTickCount has a resolution of like 10 or 16 milliseconds so if you want a millisecond but not a microsecond that's not unreasonable.
|
# ? May 27, 2014 22:11 |
|
Dessert Rose posted:It isn't used anywhere else. It's a verification check to ensure that we got to this function with the proper value in m_certMask. Also, clIdx is used as an index into a list (of certificates) later. There is no relation between the bits that a cert might have set and its position in the list. This makes it materially harder to defend the code in question, I'd say.
|
# ? May 27, 2014 23:48 |
|
http://codepad.org/7OSoeuZoPHP code:
pre:float(NAN) bool(true) bool(true) bool(true) bool(true) bool(false) ---- float(INF) bool(true) bool(true) bool(false) quote:Four mutually exclusive relations are possible: less than, equal, greater than, and unordered. The last case arises when at least one operand is NaN. Every NaN shall compare unordered with everything, including itself. The results of comparing Infinity with itself here seem Deus Rex fucked around with this message at 08:13 on May 28, 2014 |
# ? May 28, 2014 02:50 |
|
Deus Rex posted:http://codepad.org/7OSoeuZo This looks to be a fuckup that was fixed in PHP 5.4, [e: Nb. codepad.org has been mostly unmaintained for years and uses outdated versions of everything - PHP 5.2.5, Perl 5.8.0 which is 12 years old, etc] cf. http://3v4l.org/MP38b Blotto Skorzany fucked around with this message at 03:04 on May 28, 2014 |
# ? May 28, 2014 02:59 |
|
Yeah, they fixed that, but they left in the DELIGHTFUL thing where 32-bit and 64-bit platforms promote int to float at different thresholds, so you get different math results if you're operating on values between 2^32 and 2^64.
|
# ? May 28, 2014 04:20 |
|
ulmont posted:Most critically, time / freq is done in an integer context, isn't it? - http://stackoverflow.com/questions/6517435/dividing-unsigned-long-long But what if the number of milliseconds in a second changes? Then you can set MILLISECONDS_PER_SECOND to whatever the new number of milliseconds per second has become. It's like eggs, first their good for you, then they're bad, then they're good again, who knows what those crazy scientists are going to say next?!
|
# ? May 28, 2014 18:43 |
|
QuarkJets posted:But what if the number of milliseconds in a second changes? Then you can set MILLISECONDS_PER_SECOND to whatever the new number of milliseconds per second has become. It's like eggs, first their good for you, then they're bad, then they're good again, who knows what those crazy scientists are going to say next?! That would be an ABI change in the universe, in which case you file a bug report with your chosen notion of the creator, and notify your customers of the outage.
|
# ? May 28, 2014 19:36 |
|
Edison was a dick posted:That would be an ABI change in the universe, in which case you file a bug report with your chosen notion of the creator, and notify your customers of the outage. emerge world
|
# ? May 28, 2014 20:07 |
|
JawnV6 posted:emerge world topical for the coding horrors thread
|
# ? May 28, 2014 20:11 |
|
Well this is a fresh one, I am just getting into Minecraft Mod Development, I was looking at both Forgemod and Bukkit until i came across this laughable situation in 1.7.2 they are getting rid of item Ids or as they want to call them "Magic Numbers" so there is currently a method to return the object you are looking at Block block = livingEntity.getTargetBlock(null,10); Now i am developing in 1.6.4 which should not be affected except that they have deprecated ALL methods in the API including the older versions and have no replacement methods to actually do anything. Currently the 1.6.4 javadoc reads as follows getTargetBlock @Deprecated Block getTargetBlock(HashSet<Byte> transparent, int maxDistance) Deprecated. Magic value Gets the block that the living entity has targeted. Parameters: transparent - HashSet containing all transparent block IDs (set to null for only air) maxDistance - this is the maximum distance to scan (may be limited by server by at least 100 blocks, no less) Returns: block that the living entity has targeted When asking one of the devs on IRC his answer was, "someone else who hasn't read the javadocs" and when i pasted the Deprecated message he just reiterated his commment. and claimed that wasn't the javadoc. So currently in Bukkit ALL the useful methods that might use an ID have been deprecated with no replacement methods available, and no explanation why included in the javadoc either.
|
# ? May 29, 2014 10:52 |
|
Somehow, my team's bugfixes aren't making it to the QE team for verification. When a full clean and rebuild of the entire BSP only took a few seconds, I got suspicious. nightly_build.sh: code:
code:
code:
|
# ? May 29, 2014 21:13 |
|
My boss at my new job is an awesome perl greybeard, but the job is a python project so everything he writes for it just looks so horribly wrong.
|
# ? May 29, 2014 21:43 |
|
EAT THE EGGS RICOLA posted:My boss at my new job is an awesome perl greybeard, but the job is a python project so everything he writes for it just looks so horribly wrong.
|
# ? May 29, 2014 23:00 |
|
I've written too much Perl to let it appear on my résumé.
|
# ? May 30, 2014 00:42 |
|
Subjunctive posted:I've written too much Perl to let it appear on my résumé. Just like me and Android. >_<
|
# ? May 30, 2014 02:20 |
|
Doctor w-rw-rw- posted:Just like me and Android. >_< I'll get you to write objective c on android just you wait.
|
# ? May 30, 2014 02:30 |
|
Doctor w-rw-rw- posted:Just like me and Android. >_< Isn't that basically just Java?
|
# ? May 30, 2014 07:31 |
|
QuarkJets posted:Isn't that basically just Java? No, it's much worse.
|
# ? May 30, 2014 13:03 |
|
QuarkJets posted:Isn't that basically just Java? I am pretty sure he's referring to the fact that there are so many peculiarities and pain points about Android which go beyond the language. I like Android as a user. But as a developer, well, I am getting awful glad my boss is switching me back over to our iOS product team in a month.
|
# ? May 30, 2014 13:05 |
|
QuarkJets posted:Isn't that basically just Java? I adore your naivety. It makes me happy.
|
# ? May 30, 2014 13:29 |
|
Apologies if this has been posted before. Linkquote:The default setup allows an unauthenticated user to access
|
# ? May 30, 2014 13:40 |
|
|
# ? May 21, 2024 06:23 |
|
I'm guessing this isn't the best way to log JS errors in your app... global/includes/app/error_log.php php:<? $e = $_POST['e']; error_log(print_r($e, true)); ?> global/includes/app/statusbar.php code:
|
# ? May 30, 2014 14:21 |