phpjs
Version:
42 lines (31 loc) • 1.44 kB
HTML
<!-- Generated by Rakefile:build -->
<strong>
<a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a>
</strong>
on 2010-04-23 11:12:15 <br />
@ Rafał Kukawski: Looking good!
http://github.com/kvz/phpjs/commit/419ceb08a367a7f2fb564ff0dc4e2cbf2bbffe96
<hr />
<strong>
<a href="http://blog.kukawski.pl" rel="nofollow">Rafa? Kukawski</a>
</strong>
on 2010-04-22 23:27:15 <br />
I think, it would be better to handle arguments this way:
function base_convert(number, frombase, tobase){
return parseInt(number + '', frombase | 0).toString(tobase | 0);
}
frombase and tobase should be integers. When passing some other types, like float or a numeric string, PHP converts them to integer. The bitwise OR operator does more or less the same, converts the values to number and truncates the floating part of the number.
IMO, the conversion of number arguments to string is not that important, but I left it in place.
<hr />
<strong>
<a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a>
</strong>
on 2009-12-14 15:37:24 <br />
@ asd: You'd have to ask Philippe Baumann, but yes, +0 will make a difference and can prevent strange results when JavaScript automagically casts you an unexpected type : )
<hr />
<strong>
asd
</strong>
on 2009-12-03 15:44:48 <br />
What's the "+0" and "+''" for? I assume you're type-casting, but would it ever make a difference?
<hr />