Convert exponential notation of number (e+) to 10^ in JavaScript

I have a script, where I can convert gigs to megs to kilobytes to bytes to bits.

After that it uses the .toExponential function to turn it into scientific notation.

But I want it to change into an exponent, instead of it being +e# I want it to be ^#, any way I can change it to print that way instead, if not, anyway I can alter the string to change +e to ^?

Code:

console.log('calculator');
const gigabytes = 192;
console.log(`gigabytes equals ${gigabytes}`);
var megabytes = gigabytes * 1000;
console.log(`megabytes = ${megabytes}`);
var kilabytes = megabytes * 1000;
console.log (`kilabytes = ${kilabytes}`);
bytes = kilabytes * 1000;
console.log(`bytes = ${bytes}`);
bites = bytes * 8;
console.log(`bites are equal to ${bites}`);
console.log (bites.toExponential());

17 thoughts on “Convert exponential notation of number (e+) to 10^ in JavaScript”

  1. What i do not realize is in reality how you are no longer really a lot more smartly-favored than you may be right now. You are very intelligent. You recognize therefore significantly relating to this subject, produced me in my view consider it from numerous numerous angles. Its like men and women don’t seem to be interested unless it’s something to accomplish with Girl gaga! Your personal stuffs excellent. At all times care for it up!

    Reply

Leave a Comment