Reputation
9,381
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
1 20 50
Impact
~436k people reached

10h
comment Avoiding Division by Zero Using Float Comparison
It is worth mentioning that for the evaluation of sin(x)/x for small values of x, one would switch over to an asymptotic formula of it for an entire range. In the case of sin(x)/x it is easy because the asymptotic formula evaluates to be a constant of 1.0, but in other cases (different formulas), the asymptotic formula may depend on the value of x, however small it is.
11h
comment Interview question on accessing variable with pointers in c
The details are not exactly correct (see Erik Eidt's answer to see why the variable b is more likely to have been eliminated in a release build) but the line of thought is correct. For example, if we are told that the value of b is indeed written into memory, one could have written a stack scanner to search for addresses that match b's expected value, and thus recover its address, or narrow down to a few possible candidates. This adversarial mindset is necessary for some areas of software development.
13h
answered Understanding the Single-Writer Principle
16h
comment Understanding the Single-Writer Principle
"... trying to write into some proper queue" can you elaborate what you mean by "proper queue"? A queue on a single computer with low-overhead "lock-free" technique and accessed by CPUs all on cache-coherent interconnects?
16h
comment Understanding the Single-Writer Principle
Disruptor is about one-to-one direct queues (i-th producer and j-th consumer), and are supposed to run on a small number of computers (nodes) on a fast and reliable network physically located together. Facebook or AWS are about distributed queues across geographics, which require an entire book to explain, but the AWS SQS introduction gives a decent picture. It is not so much "performance-wise" but rather what you do when the system's size becomes bigger than could be fit on a single computer.
17h
comment Avoiding Division by Zero Using Float Comparison
@Alfe: I think the question you wanted to ask (but had difficulty phrasing) is really a question about error-handling philosophy: whether the caller or callee should have the bigger burden of checking for and handling a potentially failable operation.
17h
revised Avoiding Division by Zero Using Float Comparison
added 373 characters in body
17h
comment Avoiding Division by Zero Using Float Comparison
@Alfe: yes, it is likely that the caller (1) should know more about why it happens, and (2) is in a better position to decide what should be done. In some cases, the caller could specify a substitute value (0.0 or 1.0 or something else), a placeholder value (Inf, NaN, 1e+10, empty string, or something else), or to call a callback function. Of course it could also be possible that the user isn't sophisticated enough (think of the typical spreadsheet users).
17h
revised Avoiding Division by Zero Using Float Comparison
added 1504 characters in body
18h
comment Avoiding Division by Zero Using Float Comparison
@Alfe: I think you need to ask a new question and give the exact context (i.e. the bigger picture) where you see the situation (the division) happening, and then ask whether it is a context where the division should have been reformulated. On Programmers.SE you do not ask people to guess what your context would have been.
18h
comment Avoiding Division by Zero Using Float Comparison
@Alfe: on Programmers.SE you do not restrict answers to be only one side or the other.
18h
revised Avoiding Division by Zero Using Float Comparison
added 1504 characters in body
18h
comment Avoiding Division by Zero Using Float Comparison
Alfe: I side with your personal theory that it isn't normal practice to allow a computer program to proceed with a division-by-zero operation. The exception is when you are implementing a programming language (such as MATLAB) where you do not know the context / application / use-case / physical meaning of the mathematical operations it is asked to perform (where only the end-user can make sense of the formula) that you use a special representation such as Inf or NaN as a placeholder.
18h
answered Avoiding Division by Zero Using Float Comparison
18h
comment Avoiding Division by Zero Using Float Comparison
There is no universally applicable solution to the division-by-zero problem; all solutions are context-specific (or application or use-case specific). In some cases the end-users (people using the API or GUI, i.e. non-programmers) need to be told the limitations and the software's handling of such cases. Usually, each "division-by-zero" situation has an explanation that can be understood by end-users when phrased appropriately. However, you have to know what your software is being used for in order to phrase it.
Jan
10
awarded  Nice Question
Dec
19
comment How to approach syntax errors when developing a lexical analyser?
I'm voting to reopen/migrate this question because it appears to deserve a proper answer, but possibly from an audience with stronger expertise with compiler and language design. Also, it might be the case it is too broad, but this is not for us (i.e. it is only proper for people with that expertise) to decide.
Dec
17
comment Should I use HTTP status codes to describe application level events
An example is multiple (batched) requests and responses. Batching is not a restful thing; but practical efficiency concerns often necessitate some support for batching over elegance concerns.
Dec
4
answered I understand what a stack pointer is - but what is it used for?
Dec
1
comment How to avoid circular patterns in Node?
@DaveNay The simplest way to show someone how to do it is to show someone how to do it.