Avisar de contenido inadecuado

Cambiar de base con Javascript

{
}

Es posible que tengamos la necesidad de cambiar la base de un número para realizar cálculos .

Javascript nos proporciona un método muy útil para estos casos, se trata de

objeto.toSring([base])

Este método recibe opcionalmente el parámetro base.

Al especificarle una base y recuperar el valor de este método de un objecto nos devolverá su símil con el cambio de base.
Si no se especifica ninguna base, el método devolverá una cadena de texto.

Como bases tenemos disponibles  principalmente:

  • Decimal (10)      (del 0 al 9)
  • Hexadecimal (16) (del 0-9 y de la A - F )
  • Binario (2) (0 y 1)
  • Octal(8) (de 0 a 7)

Veamos el código de un ejemplo:

<script type="text/javascript">
      var numero=128;
      var decimal = "decimal : " + numero.toString();
      var hexadecimal = "hexadecimal : " + numero.toString(16);
      var octal = "octal : " + numero.toString(8);
      var binario = "binario : " + numero.toString(2);
      alert(decimal + "\r" + hexadecimal + "\r" + octal + "\r" + binario);
</script>

Con resultado:

Decimal:128
Hexadecimal:80
Octal:200
Binario:100000000

{
}
{
}

Comentarios Cambiar de base con Javascript

LSF[url=http://www.cheap-dunks.com/nike-sneaker-nike-air-yeezy-wholesale-3_39]Nike Air Yeezy[/url]
[url=http://www.cheap-dunks.com/nike-sneaker-dunk-sb-wholesale-3_40]Dunk SB[/url]
[url=http://www.cheap-dunks.com/nike-sneaker-air-force-one-wholesale-3_41]Air Force One[/url]
[url=http://www.cheap-dunks.com/nike-sneaker-nike-jordan-fusions-wholesale-3_43]Nike Jordan Fusions[/url]
[url=http://www.cheap-dunks.com/nike-sneaker-air-max-shoes-wholesale-3_44]Air Max Shoes[/url]
[url=http://www.cheap-dunks.com/nike-sneaker-air-rift-wholesale-3_46]Air Rift[/url]
[url=http://www.cheap-dunks.com/men-t-shirt-versace-men-t-shirt-wholesale-68_459]VERSACE Men T-Shirt[/url]
[url=http://www.cheap-dunks.com/men-t-shirt-g-star-t-shirt-wholesale-68_468]G-Star T-shirt[/url]
[url=http://www.cheap-dunks.com/men-t-shirt-coogi-men-t-shirt-wholesale-68_472]COOGI Men T-shirt[/url]
[url=http://www.cheap-dunks.com/men-t-shirt-black-labe-t-shirts-wholesale-68_475]BlacK Labe T-shirts[/url]
[url=http://www.cheap-dunks.com/men-t-shirt-a-f-men-t-shirt-wholesale-68_479]A&amp;F Men T-Shirt[/url]
[url=http://www.cheap-dunks.com/men-t-shirt-affliction-t-shirt-wholesale-68_480]Affliction T-shirt[/url]
[url=http://www.cheap-dunks.com/women-shoes-brand-boots-wholesale-4_47]Brand Boots[/url]
[url=http://www.cheap-dunks.com/men-short-jeans-ed-hardy-short-jeans-wholesale-70_483]ED HARDY Short Jeans[/url]
[url=http://www.cheap-dunks.com/men-short-jeans-coogi-short-jeans-wholesale-70_485]COOGI Short Jeans[/url]
[url=http://www.cheap-dunks.com/brand-belt-gucci-belt-wholesale-1_29]GUCCI Belt[/url]
[url=http://www.cheap-dunks.com/brand-belt-versace-belt-wholesale-1_34]VERSACE Belt[/url]
[url=http://www.cheap-dunks.com/brand-hats-gucci-hats-wholesale-11_119]GUCCI Hats[/url]
[url=http://www.cheap-dunks.com/brand-hats-new-era-hats-wholesale-11_121]NEW ERA Hats[/url]
[url=http://www.cheap-dunks.com/men-long-sleeve-lacoste-men-long-sleeve-wholesale-71_489]Lacoste Men Long Sleeve[/url]
[url=http://www.cheap-dunks.com/men-long-sleeve-affliction-men-long-sleeve-wholesale-71_670]Affliction Men Long Sleeve[/url]
[url=http://www.cheap-dunks.com/brand-glasses-lv-sunglasses-wholesale-10_101]LV SunGlasses[/url]
[url=http://www.cheap-dunks.com/brand-glasses-chanel-sunglasses-wholesale-10_108]Chanel SunGlasses[/url]
[url=http://www.cheap-dunks.com/brand-glasses-oakley-sunglasses-wholesale-10_116]OAKLEY SunGlasses[/url]
[url=http://www.cheap-dunks.com/brand-glasses-prada-sunglasses-wholesale-10_665]Prada SunGlasses[/url]
[url=http://www.cheap-dunks.com/kids-series-kids-shoes-wholesale-17_147]Kids Shoes[/url]
[url=http://www.cheap-dunks.com/kids-series-kids-clothing-wholesale-17_148]Kids CLothing[/url]
[url=http://www.cheap-dunks.com/men-jacket-a-f-men-coat-wholesale-74_524]A&amp;F Men Coat[/url]
[url=http://www.cheap-dunks.com/men-jacket-armani-jacket-wholesale-74_525]ARMANI Jacket[/url]
[url=http://www.cheap-dunks.com/men-jacket-lacoste-jacket-wholesale-74_533]Lacoste Jacket[/url]
[url=http://www.cheap-dunks.com/men-jacket-ed-hardy-men-jackt-wholesale-74_535]ED Hardy Men Jackt[/url]
[url=http://www.cgkicks.com/adidas-shoes-sneakers-adidas-dallas-women-wholesale-7_146]Adidas Dallas Women[/url]
[url=http://www.cgkicks.com/adidas-shoes-sneakers-adidas-memorial-edition-wholesale-7_149]Adidas Memorial Edition[/url]
[url=http://www.cgkicks.com/adidas-shoes-sneakers-superstar-women-wholesale-7_154]Superstar Women[/url]
[url=http://www.cgkicks.com/brand-belt-chanel-belts-wholesale-17_358]Chanel Belts[/url]
[url=http://www.cheap-dunks.com/brand-jewelry-necklace-wholesale-14_132]<FONT color=#111111 size=2]Necklace</FONT][/url]
Air Max Shoes Air Max Shoes 01/07/2010 a las 04:09
lsf<A href="http://www.cheap-dunks.com/nike-sneaker-nike-air-yeezy-wholesale-3_39">Nike Air Yeezy</A>
<A href="http://www.cheap-dunks.com/nike-sneaker-dunk-sb-wholesale-3_40">Dunk SB</A>
<A href="http://www.cheap-dunks.com/nike-sneaker-air-force-one-wholesale-3_41">Air Force One</A>
<A href="http://www.cheap-dunks.com/nike-sneaker-nike-jordan-fusions-wholesale-3_43">Nike Jordan Fusions</A>
<A href="http://www.cheap-dunks.com/nike-sneaker-air-max-shoes-wholesale-3_44">Air Max Shoes</A>
<A href="http://www.cheap-dunks.com/nike-sneaker-air-rift-wholesale-3_46">Air Rift</A>
<A href="http://www.cheap-dunks.com/men-t-shirt-versace-men-t-shirt-wholesale-68_459">VERSACE Men T-Shirt</A>
<A href="http://www.cheap-dunks.com/men-t-shirt-g-star-t-shirt-wholesale-68_468">G-Star T-shirt</A>
<A href="http://www.cheap-dunks.com/men-t-shirt-coogi-men-t-shirt-wholesale-68_472">COOGI Men T-shirt</A>
<A href="http://www.cheap-dunks.com/men-t-shirt-black-labe-t-shirts-wholesale-68_475">BlacK Labe T-shirts</A>
<A href="http://www.cheap-dunks.com/men-t-shirt-a-f-men-t-shirt-wholesale-68_479">A&amp;F Men T-Shirt</A>
<A href="http://www.cheap-dunks.com/men-t-shirt-affliction-t-shirt-wholesale-68_480">Affliction T-shirt</A>
<A href="http://www.cheap-dunks.com/women-shoes-brand-boots-wholesale-4_47">Brand Boots</A>
<A href="http://www.cheap-dunks.com/men-short-jeans-ed-hardy-short-jeans-wholesale-70_483">ED HARDY Short Jeans</A>
<A href="http://www.cheap-dunks.com/men-short-jeans-coogi-short-jeans-wholesale-70_485">COOGI Short Jeans</A>
<A href="http://www.cheap-dunks.com/brand-belt-gucci-belt-wholesale-1_29">GUCCI Belt</A>
<A href="http://www.cheap-dunks.com/brand-belt-versace-belt-wholesale-1_34">VERSACE Belt</A>
<A href="http://www.cheap-dunks.com/brand-hats-gucci-hats-wholesale-11_119">GUCCI Hats</A>
<A href="http://www.cheap-dunks.com/brand-hats-new-era-hats-wholesale-11_121">NEW ERA Hats</A>
<A href="http://www.cheap-dunks.com/men-long-sleeve-lacoste-men-long-sleeve-wholesale-71_489">Lacoste Men Long Sleeve</A>
<A href="http://www.cheap-dunks.com/men-long-sleeve-affliction-men-long-sleeve-wholesale-71_670">Affliction Men Long Sleeve</A>
<A href="http://www.cheap-dunks.com/brand-glasses-lv-sunglasses-wholesale-10_101">LV SunGlasses</A>
<A href="http://www.cheap-dunks.com/brand-glasses-chanel-sunglasses-wholesale-10_108">Chanel SunGlasses</A>
<A href="http://www.cheap-dunks.com/brand-glasses-oakley-sunglasses-wholesale-10_116">OAKLEY SunGlasses</A>
<A href="http://www.cheap-dunks.com/brand-glasses-prada-sunglasses-wholesale-10_665">Prada SunGlasses</A>
<A href="http://www.cheap-dunks.com/kids-series-kids-shoes-wholesale-17_147">Kids Shoes</A>
<A href="http://www.cheap-dunks.com/kids-series-kids-clothing-wholesale-17_148">Kids CLothing</A>
<A href="http://www.cheap-dunks.com/men-jacket-a-f-men-coat-wholesale-74_524">A&amp;F Men Coat</A>
<A href="http://www.cheap-dunks.com/men-jacket-armani-jacket-wholesale-74_525">ARMANI Jacket</A>
<A href="http://www.cheap-dunks.com/men-jacket-lacoste-jacket-wholesale-74_533">Lacoste Jacket</A>
<A href="http://www.cheap-dunks.com/men-jacket-ed-hardy-men-jackt-wholesale-74_535">ED Hardy Men Jackt</A>
<A href="http://www.cgkicks.com/adidas-shoes-sneakers-adidas-dallas-women-wholesale-7_146">Adidas Dallas Women</A>
<A href="http://www.cgkicks.com/adidas-shoes-sneakers-adidas-memorial-edition-wholesale-7_149">Adidas Memorial Edition</A>
<A href="http://www.cgkicks.com/adidas-shoes-sneakers-superstar-women-wholesale-7_154">Superstar Women</A>
<A href="http://www.cgkicks.com/brand-belt-chanel-belts-wholesale-17_358">Chanel Belts</A>
<A href="http://www.cheap-dunks.com/brand-jewelry-necklace-wholesale-14_132"><FONT color=#111111 size=2>Necklace</FONT></A>

Deja tu comentario Cambiar de base con Javascript

Identifícate en OboLog, o crea tu blog gratis si aún no estás registrado.

Avatar de usuario Tu nombre