2,858 reputation
11121
bio website
location
age
visits member for 3 years, 8 months
seen Sep 12 at 16:28

May
14
comment Single codebase for client and server with Node.js
@hippietrail, en.wikipedia.org/wiki/WAR_file_format_(Sun)
May
4
comment Is there any situation when there's no alternative to instanceof?
There's a variant on the second approach which can be used in e.g. Java: try an explicit cast and be ready to catch the ClassCastException. It's probably open for debate whether this is really just hiding an instanceof check behind syntactic sugar.
Apr
26
comment Why does Donald Knuth write TAOCP using assembly language?
Knuth implemented an ALGOL compiler in 1960, and ALGOL was intended to be suitable for publishing algorithms, so I don't think this really answers the question.
Apr
17
comment Does any well-known license require to make modifications available when only derived *output* is published?
The GPL itself claims to be protected by copyright, so unless the lawyer / law student thinks they have a solid argument that it's ineligible, they might be reluctant to create an unauthorised derived work.
Apr
5
comment Implementing base-10 floating point division
Your multiplication is a bit overkill. You're multiplying two 9-digit numbers, so the result will have 17 or 18 digits. You then want to reduce to 9 digits, so you're dropping 8 or 9 digits. Therefore you can safely drop the bottom 3 digits from each number before multiplying, and eliminate all of the terms containing C or F.
Apr
3
comment Is (1/(1/x)) always a perfect round trip?
Nice use of the pigeonhole principle. It can be extended to get a bound equal to my estimate for the number of collisions. For x in (1, 2), the range (x, 2) maps onto the range (0.5, x^-1), so given the difference in ulp the proportion of collisions is at least (2 - x) - 2(x^-1 - 0.5) = 3 - x - 2x^-1. Differentiate: this has extrema when -1 + 2x^-2 = 0 i.e. x^2 = 2. Only the positive root is in range, so we get that the proportion of collisions is at least 3 - sqrt(2) - 2/sqrt(2) = 3 - 2sqrt(2).
Apr
1
comment Is (1/(1/x)) always a perfect round trip?
@MichaelShaw, there's no good reason to expect that the reciprocal should even be injective, which would be a precondition for double-reciprocal to round-trip. However, there's a difference between a) stating without proof that there's probably at least one number that doesn't round-trip; b) calculating and justifying an estimate for the number of mantissas which don't round-trip; c) proving that at least one mantissa doesn't round-trip. I would be quite interested to see a careful analysis which shows how good or bad my empirical measurement is.
Apr
1
comment Is (1/(1/x)) always a perfect round trip?
Empirically your rule of thumb is wrong: it returns true for slightly over 80% of values of x.
Apr
1
comment Is (1/(1/x)) always a perfect round trip?
You cannot conclude from the fact that 1/x can't be represented exactly that 1/(1/x) != x. To take your example, in 3.s.f. decimal floating point, 1.00 / 3.00 = 0.333, and 1.00 / 0.333 is 3.00. That particular mantissa is a fixed point of the double-reciprocal in that floating point scheme.
Mar
21
comment Why interviewers want Optimal Algorithms
Are you sure they were doubtful about the correctness and not just wanting to see how clearly you were capable of explaining its working?
Mar
20
comment Login on every page requires SSL on all pages
FWIW some XSS vectors would allow the attacker to send information to an attacker-controlled site even if the page with the login form is only sent over HTTPS.
Feb
27
comment Validating Emails in PHP
@AmgadSuliman, probably not, but if you download IsEmail you can use its test suite to check most if not all of the corner cases.
Feb
26
comment Tineye.com search algorithm?
@ScottWhitlock, there is an obvious approach to the problem, which is wavelet compression followed by quantising and prefix matching. Whether that's what tineye uses, I don't know.
Feb
16
comment How does if/else work internally in all programming languages?
@Neil, depends on the processor's instruction set. ARM has some interesting stuff with conditional instructions.
Feb
6
comment Why use partial classes?
Mixins. This could be combined with T4 to avoid manual copying...
Jan
2
comment Evaluate math expressions without a stack
The approach of factoring out the a*b term works mathematically, assuming that we're using real numbers, rational numbers, or something structurally similar. But it wouldn't necessarily give the same result if we're using float, and it certainly wouldn't give the same result if we're using int (e.g. 7/2*2 gives 6). The question doesn't say what it's using, but from the comments it's definitely using int.
Jan
2
comment Evaluate math expressions without a stack
This assumes operation over a field, which isn't stated in the question and is unlikely in practice (as neither the integers nor IEEE-854 floating point representations are fields).
Jan
2
comment Evaluate math expressions without a stack
@Blrfl, I think the idea is to use a more powerful machine as the compiler.
Dec
21
comment Are all security threats triggered by software bugs?
@JoachimSauer, what if your website refuses to transfer any information over HTTP and it's actually a MITM who's mapping HTTP to HTTPS? While browsers support HTTP and routers permit it to pass there's a vulnerability to sniffing which can only be avoided by extremely security-conscious clients. So really the question becomes: is it a bug for web browsers to support HTTP?
Dec
1
comment Should I encrypt data in database?
The user is going to log on with their password and then have access to the data, so the data is no more secure than the user's password no matter what method you use to get from password to key. You should refuse to allow the user to set their password to 12345 with an entropy checker which takes into account simple patterns (e.g. port zxcvbn).