How would you solve this 'interview' question in D?

MattCodr mattcoder at hotmail.com
Thu Jun 27 09:46:51 PDT 2013


On Thursday, 27 June 2013 at 16:02:59 UTC, John Colvin wrote:
> On Thursday, 27 June 2013 at 15:32:05 UTC, MattCodr wrote:
>> On Thursday, 27 June 2013 at 12:38:25 UTC, John Colvin wrote:
>>> The question is ambiguous as to what they mean by -n. Do they 
>>> mean the result of negation on the 32bit signed int, or do 
>>> they mean the negative of the number represented by that int. 
>>> this matters because -int.min evaluates to int.min due to 
>>> wraparound.
>>
>> From: February 11, 2008:
>>
>> Vlad Patryshev said...
>>
>> ...Write a function f on 32-bit integers that, applied twice, 
>> it negates the integer. f(f(n)) = -n.
>>
>> Source: 
>> http://steve-yegge.blogspot.com.br/2008/02/portrait-of-n00b.html
>>
>> Matheus.
>
> How is that any more specific?

In fact it isn't. This was all that I collected about the problem 
(at work).


More information about the Digitalmars-d-learn mailing list