[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
(x - a) % b + a Can this be simplified so a occurs just once?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 8
Thread images: 1
(x - a) % b + a

Can this be simplified so a occurs just once?
>>
>>>/sci/
>>
>>53705525
/homework/ is that way >>>/sci/
>>
function rot13(text) {
return text.replace(/[A-Z]/ig, function(ch) {
var base = ch > "Z" ? "a".charCodeAt(0) : "A".charCodeAt(0);
return String.fromCharCode((ch.charCodeAt(0) - base + 13) % 26 + base);
});
}


I want to condense the code so base only occurs once. Is it possible?
>>
>>53705525
not without redefining x as a multiple of a
>>
int a = a();
>>
>>53705525
who cares. The compiler is smarter at optimization than you are.
>>
>>53705843

ok i was just wondering
Thread replies: 8
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.