last day (15 days later) » 

21:09
1
Q: Make some noise-cancelling headphones

wizzwizz4I am in desperate need of some ear defenders, so I can program in peace. Unfortunately, I don't have ear defenders. But I do have a pair of headphones, a microphone and a microcontroller, so I thought I'd make some noise-cancelling headphones. However, there is one tiny problem. I can't program ...

Why require STDIN/STDOUT? I don't see a reason why we shouldn't be allowed to use function arguments/returns values instead.
Although, there is a good reason you shouldn't be allowed to; it would be a bit of a rubbish noise-canceller if there wasn't any cancelling until all the bytes had been received through the microphone!
@xnor It has to not be given in Hex. I just didn't think it would be easy to read NULL and DEL characters. You need to output as a byte stream. (I'll update the question.)
@xnor An arbitrary-sized number or a string of bytes is an acceptable replacement for a byte-stream.
@CatsAreFluffy Of course; this wouldn't be code-golf if you were just golfing my code!
For a complement of 255 and a modifier of 2 I get 191 and not 255 again like in your example. I am calculating it with floor( (255-128)/2 + 128) Am I doing something wrong?
@DenkerAffe No, all of my examples are broken. I need to fix them.
Are you sure about the output for 224 and modifier 128? I get ceil(127 - ((127 - 31)/128)) = 127 and not 121
21:09
@DenkerAffe Fixed them now!
You sure about the modifier 0.5? This gives me values over 300. (255-128)*2+128=382
@DenkerAffe What would be the correct wording for "values more than 0xff should be 0xff, and values less than 0x00 should be 0x00?
@wizzwizz4 max(min(d,255),0) should do the job if you want to be concise. Your text desciption works as well tho.
I'm not sure why this moved to chat...
SE does this automatically if comments turn into a long conversation.
21:14
Ok. Well, do you think there's a better wording for that?
Ooh: "clipped".
I think what you had in mind is fine
Just make sure to sandbxo your post next time, this had too be revised way too much.
 
2 hours later…

last day (15 days later) »