big steppy
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

615 lines
22 KiB

  1. 'use strict';
  2. function round(number, precision = 3) {
  3. return Math.round(number * Math.pow(10, precision)) / Math.pow(10, precision);
  4. }
  5. function numberRough(value, suffix = "") {
  6. if (value == 1) {
  7. return "a single";
  8. } else if (value < 5) {
  9. return "a few";
  10. } else if (value < 12) {
  11. return "a handful " + suffix;
  12. } else if (value == 12) {
  13. return "a dozen";
  14. } else {
  15. var scale = Math.floor(Math.log10(value));
  16. switch (scale) {
  17. case 1: return "dozens " + suffix;
  18. case 2: return "hundreds " + suffix;
  19. default:
  20. let prefix = "";
  21. if (scale % 3 == 1)
  22. prefix = "tens of ";
  23. else if (scale % 3 == 2)
  24. prefix = "hundreds of ";
  25. let order = Math.floor(scale / 3);
  26. switch (order) {
  27. case 1: return prefix + "thousands " + suffix;
  28. case 2: return prefix + "millions " + suffix;
  29. case 3: return prefix + "billions " + suffix;
  30. case 4: return prefix + "trillions " + suffix;
  31. case 5: return prefix + "quadrillions " + suffix;
  32. case 6: return prefix + "quintillions " + suffix;
  33. default: return "uncountably many";
  34. }
  35. }
  36. }
  37. }
  38. function fixedIfDecimal(num, fixed) {
  39. if (fixed === undefined)
  40. return num.toString();
  41. else;
  42. return num.toFixed(fixed);
  43. }
  44. function number(value, type = "full", fixed) {
  45. var val = parseFloat(value);
  46. switch (type) {
  47. case "full":
  48. if (Math.log(value) / Math.log(10) < 10) {
  49. return fixedIfDecimal(val, fixed);
  50. }
  51. case "scientific": return val.toExponential(3, fixed).toString();
  52. case "words": return number_words_repeated(val, fixed);
  53. case "prefix": return number_prefix(val, fixed);
  54. }
  55. }
  56. function number_words(value) {
  57. var scale = Math.floor(Math.log(value) / Math.log(1000));
  58. if (scale < 0) {
  59. return fixedIfDecimal(value, fixed);
  60. }
  61. switch (scale) {
  62. case 0: return value.toString();
  63. case 1: return Math.round(value / 1e3).toString() + " thousand";
  64. case 2: return Math.round(value / 1e6).toString() + " million";
  65. case 3: return Math.round(value / 1e9).toString() + " billion";
  66. case 4: return Math.round(value / 1e12).toString() + " trillion";
  67. case 5: return Math.round(value / 1e15).toString() + " quadrillion";
  68. case 6: return Math.round(value / 1e18).toString() + " quintillion";
  69. case 7: return Math.round(value / 1e21).toString() + " sextillion";
  70. case 8: return Math.round(value / 1e24).toString() + " septillion";
  71. case 9: return Math.round(value / 1e27).toString() + " octillion";
  72. case 10: return Math.round(value / 1e30).toString() + " nonillion";
  73. case 11: return Math.round(value / 1e33).toString() + " decillion";
  74. case 12: return Math.round(value / 1e36).toString() + " undecillion";
  75. case 13: return Math.round(value / 1e39).toString() + " duodecillion";
  76. case 14: return Math.round(value / 1e42).toString() + " tredecillion";
  77. case 15: return Math.round(value / 1e45).toString() + " quattuordecillion";
  78. case 16: return Math.round(value / 1e48).toString() + " quindecillion";
  79. case 17: return Math.round(value / 1e51).toString() + " sexdecillion";
  80. case 18: return Math.round(value / 1e54).toString() + " septendecillion";
  81. case 19: return Math.round(value / 1e57).toString() + " octodecillion";
  82. case 20: return Math.round(value / 1e60).toString() + " novemdecillion";
  83. default: return Math.round(value / 1e63).toString() + " vigintillion";
  84. }
  85. }
  86. function number_words_repeated(value, fixed) {
  87. if (value == Infinity)
  88. return "a lot of";
  89. var scale = Math.floor(Math.log(value) / Math.log(1000));
  90. if (scale < 0)
  91. return fixedIfDecimal(value, fixed);
  92. switch (scale) {
  93. case 0: return fixedIfDecimal(value, fixed);
  94. case 1: return Math.round(value / 1e3).toString() + " thousand";
  95. case 2: return Math.round(value / 1e6).toString() + " million";
  96. case 3: return Math.round(value / 1e9).toString() + " billion";
  97. case 4: return Math.round(value / 1e12).toString() + " trillion";
  98. case 5: return Math.round(value / 1e15).toString() + " quadrillion";
  99. case 6: return Math.round(value / 1e18).toString() + " quintillion";
  100. case 7: return Math.round(value / 1e21).toString() + " sextillion";
  101. case 8: return Math.round(value / 1e24).toString() + " septillion";
  102. case 9: return Math.round(value / 1e27).toString() + " octillion";
  103. case 10: return Math.round(value / 1e30).toString() + " nonillion";
  104. case 11: return Math.round(value / 1e33).toString() + " decillion";
  105. default: return number_words_repeated(value / 1e33) + " decillion";
  106. }
  107. }
  108. function number_prefix(value, fixed) {
  109. var scale = Math.floor(Math.log(value) / Math.log(1000));
  110. if (scale < 0)
  111. return fixedIfDecimal(value, fixed);
  112. switch (scale) {
  113. case 0: return fixedIfDecimal(value, fixed);
  114. case 1: return Math.round(value / 1e3).toString() + "K";
  115. case 2: return Math.round(value / 1e6).toString() + "M";
  116. case 3: return Math.round(value / 1e9).toString() + "G";
  117. case 4: return Math.round(value / 1e12).toString() + "T";
  118. case 5: return Math.round(value / 1e15).toString() + "P";
  119. case 6: return Math.round(value / 1e18).toString() + "E";
  120. case 7: return Math.round(value / 1e21).toString() + "Z";
  121. default: return Math.round(value / 1e24).toString() + "Y";
  122. }
  123. }
  124. function mass(kg, type = "metric", singular = false) {
  125. switch (type) {
  126. case "metric": return metricMass(kg, singular);
  127. case "SI": return metricSymMass(kg, singular);
  128. case "customary": return customaryMass(kg, singular);
  129. case "US": return customarySymMass(kg, singular);
  130. case "approx": return approxMass(kg, singular);
  131. }
  132. }
  133. function length(m, type = "metric", singular = false) {
  134. switch (type) {
  135. case "metric": return metricLength(m, singular);
  136. case "SI": return metricSymLength(m, singular);
  137. case "customary": return customaryLength(m, singular);
  138. case "US": return customarySymLength(m, singular);
  139. case "approx": return approxLength(m, singular);
  140. }
  141. }
  142. function area(m2, type = "metric", singular = false) {
  143. switch (type) {
  144. case "metric": return metricArea(m2, singular);
  145. case "SI": return metricSymArea(m2, singular);
  146. case "customary": return customaryArea(m2, singular);
  147. case "US": return customarySymArea(m2, singular);
  148. case "approx": return approxArea(m2, singular);
  149. }
  150. }
  151. function volume(m3, type = "metric", singular = false) {
  152. switch (type) {
  153. case "metric": return metricVolume(m3, singular);
  154. case "SI": return metricSymVolume(m3, singular);
  155. case "customary": return customaryVolume(m3, singular);
  156. case "US": return customarySymVolume(m3, singular);
  157. case "approx": return approxVolume(m3, singular);
  158. }
  159. }
  160. function metricMass(kg, singular = false) {
  161. if (kg < 1 / 1000) {
  162. let mass = round(kg * 1e6, 0);
  163. return mass + (singular || mass == 1 ? " milligram" : " milligrams");
  164. } else if (kg < 1) {
  165. let mass = round(kg * 1000, 0);
  166. return mass + (singular || mass == 1 ? " gram" : " grams");
  167. } else if (kg < 5000) {
  168. let mass = round(kg, 0);
  169. return mass + (singular || mass == 1 ? " kilogram" : " kilograms");
  170. } else if (kg < 5000000) {
  171. let mass = round(kg / 1000, 1);
  172. return mass + (singular || mass == 1 ? " metric ton" : " metric tons");
  173. } else if (kg < 5000000000) {
  174. let mass = round(kg / 1000000, 1);
  175. return mass + (singular || mass == 1 ? " kiloton" : " kilotons");
  176. } else if (kg < 5000000000000) {
  177. let mass = round(kg / 1000000000, 1);
  178. return mass + (singular || mass == 1 ? " megaton" : " megatons");
  179. } else {
  180. let mass = round(kg / 1000000000000, 1);
  181. return mass + (singular || mass == 1 ? " gigaton" : " gigatons");
  182. }
  183. }
  184. function metricSymMass(kg, singular = false) {
  185. if (kg < 1 / 1000) {
  186. let mass = round(kg * 1e6, 0);
  187. return mass + " mg";
  188. } else if (kg < 1) {
  189. let mass = round(kg * 1000, 0);
  190. return mass + " g";
  191. } else if (kg < 5000) {
  192. let mass = round(kg, 0);
  193. return mass + " kg";
  194. } else if (kg < 5000000) {
  195. let mass = round(kg / 1000, 1);
  196. return mass + " t";
  197. } else if (kg < 5000000000) {
  198. let mass = round(kg / 1000000, 1);
  199. return mass + " kt";
  200. } else if (kg < 5000000000000) {
  201. let mass = round(kg / 1000000000, 1);
  202. return mass + " mt";
  203. } else {
  204. let mass = round(kg / 1000000000000, 1);
  205. return mass + " gt";
  206. }
  207. }
  208. function customaryMass(kg, singular = false) {
  209. let lbs = kg * 2.2;
  210. if (lbs < 1) {
  211. let mass = round(lbs * 16, 0);
  212. return mass + (singular || mass == 1 ? " ounce" : " ounces");
  213. } else if (lbs < 2000) {
  214. let mass = round(lbs, 0);
  215. return mass + (singular || mass == 1 ? " pound" : " pounds");
  216. } else {
  217. let mass = round(lbs / 2000, 1);
  218. return mass + (singular || mass == 1 ? " ton" : " tons");
  219. }
  220. }
  221. function customarySymMass(kg, singular = false) {
  222. let lbs = kg * 2.2;
  223. if (lbs < 1) {
  224. let mass = round(lbs * 16, 0);
  225. return mass + " oz";
  226. } else if (lbs < 2000) {
  227. let mass = round(lbs, 0);
  228. return mass + (singular || mass == 1 ? " lb" : " lbs");
  229. } else {
  230. let mass = round(lbs / 2000, 1);
  231. return mass + (singular || mass == 1 ? " ton" : " tons");
  232. }
  233. }
  234. function approxMass(kg, singular = false) {
  235. if (kg < 4500) {
  236. let mass = round(kg / 1000, 2);
  237. return mass + (singular || mass == 1 ? "car" : " cars");
  238. } else if (kg < 54431) {
  239. let mass = round(kg / 6000, 2);
  240. return mass + (singular || mass == 1 ? " elephant" : " elephants");
  241. //this unit almost never gets used and is mostly redundant, perhaps remove it if units are cleaned up
  242. } else if (kg < 10000000) {
  243. let mass = round(kg / 54431.1, 2);
  244. return mass + (singular || mass == 1 ? " tank" : " tanks");
  245. } else if (kg < 5.2e10) {
  246. let mass = round(kg / 9.7e7, 2);
  247. return mass + (singular || mass == 1 ? " aircraft carrier" : " aircraft carriers");
  248. } else if (kg < 1.5e13) {
  249. let mass = round(kg / 5.2e10, 2);
  250. return mass + (singular || mass == 1 ? " Great Wall of China" : " Great Wall Of Chinas");
  251. } else if (kg < 5e21) {
  252. let mass = round(kg / 1.5e15, 2);
  253. return mass + (singular || mass == 1 ? " New York City" : " New York Cities");
  254. //this figure includes a lot of underlying bedrock, just the city itself is 1.13587210581190e11 but I needed a good figure to fit in this spot
  255. } else if (kg < 6e23) {
  256. let mass = round(kg / 4.6e20, 2);
  257. return mass + (singular || mass == 1 ? " Australia" : " Australias");
  258. //this is a napkin math number based on the land area of Australia, 25km of height, and rough density of rock
  259. } else if (kg < 2e27) {
  260. let mass = round(kg / 6e24, 2);
  261. return mass + (singular || mass == 1 ? " Earth" : " Earths");
  262. } else if (kg < 1.4e39) {
  263. let mass = round(kg / 2e30, 2);
  264. return mass + (singular || mass == 1 ? " Sun" : " Suns");
  265. } else {
  266. let mass = round(kg / 1.4e42, 2);
  267. return mass + (singular || mass == 1 ? " Milky Way" : " Milky Ways");
  268. }
  269. }
  270. function metricLength(m, singular = false) {
  271. if (m < 1 / 100) {
  272. let length = round(m * 1000, 2);
  273. return length + (singular || length == 1 ? " millimeter" : " millimeters");
  274. } else if (m < 1) {
  275. let length = round(m * 100, 0);
  276. return length + (singular || length == 1 ? " centimeter" : " centimeters");
  277. } else if (m < 500) {
  278. let length = round(m, 2);
  279. return length + (singular || length == 1 ? " meter" : " meters");
  280. } else if (m < 1e12) {
  281. let length = round(m / 1000, 1);
  282. return length + (singular || length == 1 ? " kilometer" : " kilometers");
  283. } else if (m < 1e15) {
  284. let length = round(m / 1e6, 1);
  285. return length + (singular || length == 1 ? " megameter" : " megameters");
  286. } else if (m < 1e18) {
  287. let length = round(m / 1e9, 1);
  288. return length + (singular || length == 1 ? " gigameter" : " gigameters");
  289. } else {
  290. let length = round(m / 1e12, 1);
  291. return length + (singular || length == 1 ? " terameter" : " terameters");
  292. }
  293. }
  294. function metricSymLength(m, singular = false) {
  295. if (m < 1 / 100) {
  296. let length = round(m * 1000, 2);
  297. return length + " mm";
  298. } else if (m < 1) {
  299. let length = round(m * 100, 0);
  300. return length + " cm";
  301. } else if (m < 500) {
  302. let length = round(m, 2);
  303. return length + " m";
  304. } else {
  305. let length = round(m / 1000, 1);
  306. return length + " km";
  307. }
  308. }
  309. function customaryLength(m, singular = false) {
  310. let ft = m * 3.28084;
  311. if (ft < 1) {
  312. let length = round(ft * 12, 0);
  313. return length + (singular || length == 1 ? " inch" : " inches");
  314. } else if (ft < 5280) {
  315. let end = customaryLength((ft - Math.floor(ft)) / 3.28084, singular);
  316. let length = Math.floor(ft);
  317. return length + (singular || length == 1 ? " foot" : " feet") + " " + end;
  318. } else {
  319. let length = round(ft / 5280, 1);
  320. return length + (singular || length == 1 ? " mile" : " miles");
  321. }
  322. }
  323. function customarySymLength(m, singular = false) {
  324. let ft = m * 3.28084;
  325. if (ft < 1) {
  326. let length = round(ft * 12, 0);
  327. return length + "\"";
  328. } else if (ft < 5280) {
  329. let end = customarySymLength((ft - Math.floor(ft)) / 3.28084, singular);
  330. let length = Math.floor(ft);
  331. return length + "'" + " " + end;
  332. } else {
  333. let length = round(ft / 5280, 1);
  334. return length + " mi";
  335. }
  336. }
  337. function approxLength(m, singular = false) {
  338. if (m < 25) {
  339. let length = round(m / 1.9, 1);
  340. return length + (singular || length == 1 ? " person" : " people");
  341. } else if (m < 350) {
  342. let length = round(m / 49, 1);
  343. return length + (singular || length == 1 ? " football field" : " football fields");
  344. } else if (m < 20000) {
  345. let length = round(m / 449, 1);
  346. return length + (singular || length == 1 ? " Empire State Building" : " Empire State Buildings");
  347. } else if (m < 2000000) {
  348. let length = round(m / 80467.2, 1);
  349. return length + (singular || length == 1 ? " Panama Canal" : " Panama Canals");
  350. } else if (m < 3474574 * 2) {
  351. let length = round(m / 3474574, 1);
  352. return length + (singular || length == 1 ? " Moon" : " moons");
  353. } else if (m < 12.742e6 * 130) {
  354. let length = round(m / 12.742e6, 2);
  355. return length + (singular || length == 1 ? " Earth" : " earths");
  356. } else if (m < 149.6e12) {
  357. let length = round(m / 149.6e9, 3);
  358. return length + (singular || length == 1 ? " AU" : " AUs");
  359. } else if (m < 9.4607e22) {
  360. let length = round(m / 9.4607e15, 3);
  361. return length + (singular || length == 1 ? " light year" : " light years");
  362. } else if (m < 3e19) {
  363. let length = round(m / 3.0856776e16, 3);
  364. return length + (singular || length == 1 ? " parsec" : " parsecs");
  365. } else if (m < 3e22) {
  366. let length = round(m / 3.0856776e19, 3);
  367. return length + (singular || length == 1 ? " kiloparsec" : " kiloparsecs");
  368. } else if (m < 3e25) {
  369. let length = round(m / 3.0856776e22, 3);
  370. return length + (singular || length == 1 ? " megaparsec" : " megaparsecs");
  371. } else if (m < 3e28) {
  372. let length = round(m / 3.0856776e25, 3);
  373. return length + (singular || length == 1 ? " gigaparsec" : " gigaparsecss");
  374. } else {
  375. let length = round(m / 3.0856776e28, 3);
  376. return length + (singular || length == 1 ? " teraparsec" : " teraparsecs");
  377. }
  378. }
  379. function metricArea(m2, singular = false) {
  380. if (m2 < 1 / 10) {
  381. let area = round(m2 * 10000, 2);
  382. return area + (singular || area == 1 ? " square centimeter" : " square centimeters");
  383. } else if (m2 < 100000) {
  384. let area = round(m2, 2);
  385. return area + (singular || area == 1 ? " square meter" : " square meters");
  386. } else {
  387. let area = round(m2 / 1e6, 2);
  388. return area + (singular || area == 1 ? " kilometer" : " square kilometers");
  389. }
  390. }
  391. function metricSymArea(m2, singular = false) {
  392. if (m2 < 1 / 10) {
  393. let area = round(m2 * 10000, 2);
  394. return area + " cm" + "2".sup();
  395. } else if (m2 < 100000) {
  396. let area = round(m2, 2);
  397. return area + " m" + "2".sup();
  398. } else {
  399. let area = round(m2 / 1e6, 2);
  400. return area + " km" + "2".sup();
  401. }
  402. }
  403. function customaryArea(m2, singular = false) {
  404. let ft2 = m2 * 3.28084 * 3.28084;
  405. if (ft2 < 1) {
  406. let area = round(ft2 * 144, 0);
  407. return area + (singular || area == 1 ? " square inch" : " square inches");
  408. } else if (ft2 < 5280 * 5280 / 10) {
  409. let area = round(ft2, 1);
  410. return area + (singular || area == 1 ? " square foot" : " square feet");
  411. } else {
  412. let area = round(ft2 / 5280 / 5280, 1);
  413. return area + (singular || area == 1 ? " square mile" : " square miles");
  414. }
  415. }
  416. function customarySymArea(m2, singular = false) {
  417. if (m2 < 1 / 10) {
  418. let area = round(m2 * 10000, 2);
  419. return area + " in" + "2".sup();
  420. } else if (m2 < 100000) {
  421. let area = round(m2, 2);
  422. return area + " ft" + "2".sup();
  423. } else {
  424. let area = round(m2 / 1e6, 2);
  425. return area + " mi" + "2".sup();
  426. }
  427. }
  428. function approxArea(m2, singular = false) {
  429. if (m2 < 20000) {
  430. let area = round(m2 / 5341.85, 1);
  431. return area + (singular || area == 1 ? " football field" : " football fields");
  432. } else if (m2 < 9.36e+15) {
  433. let area = round(m2 / 10117.1, 1);
  434. return area + (singular || area == 1 ? " block" : " blocks");
  435. } else if (m2 < 3.7920361e+13) {
  436. let area = round(m2 / 9.36e+8, 1);
  437. return area + (singular || area == 1 ? " city" : " cities");
  438. } else if (m2 < 9.4800902e+18) {
  439. let area = round(m2 / 9.4800902e+12, 1);
  440. return area + (singular || area == 1 ? " moon" : " moons");
  441. } else if (m2 < 2.8118957330513e+42) {
  442. let area = round(m2 / 6.4900004e+28, 1);
  443. return area + (singular || area == 1 ? " solar system" : " solar systems");
  444. } else {
  445. let area = round(m2 / 2.8118957330513e+42, 1);
  446. return area + (singular || area == 1 ? " milky way" : " milky ways");
  447. }
  448. }
  449. function metricVolume(m3, singular = false) {
  450. if (m3 < 1 / 1000) {
  451. let volume = round(m3 * 1e6, 0);
  452. return volume + (singular || volume == 1 ? " milliliter" : " milliliters");
  453. } else if (m3 < 1) {
  454. let volume = round(m3 * 1000, 1);
  455. return volume + (singular || volume == 1 ? " liter" : " liters");
  456. } else if (m3 < 1000000) {
  457. let volume = round(m3, 0);
  458. return volume + (singular || volume == 1 ? " cubic meter" : " cubic meters");
  459. } else if (m3 < 1e12) {
  460. let volume = round(m3 / 1e9, 3);
  461. return volume + (singular || volume == 1 ? " cubic kilometer" : " cubic kilometers");
  462. } else {
  463. let volume = round(m3 / 1e9, 0);
  464. return volume + (singular || volume == 1 ? " cubic kilometer" : " cubic kilometers");
  465. }
  466. }
  467. function metricSymVolume(m3, singular = false) {
  468. if (m3 < 1 / 1000) {
  469. let volume = round(m3 * 1e6, 0);
  470. return volume + " mL";
  471. } else if (m3 < 1) {
  472. let volume = round(m3 * 1000, 1);
  473. return volume + " L";
  474. } else if (m3 < 1000000) {
  475. let volume = round(m3, 0);
  476. return volume + " m" + "³";
  477. } else if (m3 < 1e12) {
  478. let volume = round(m3 / 1e9, 3);
  479. return volume + " km" + "³";
  480. } else {
  481. let volume = round(m3 / 1e9, 0);
  482. return volume + " km" + "³";
  483. }
  484. }
  485. function customaryVolume(m3, singular = false) {
  486. let gallons = m3 * 264.172;
  487. if (gallons < 1 / 16) {
  488. let volume = round(gallons * 128, 0);
  489. return volume + (singular || volume == 1 ? " fluid ounce" : " fluid ounces");
  490. } else if (gallons < 1 / 4) {
  491. let volume = round(gallons * 16, 1);
  492. return volume + (singular || volume == 1 ? " cup" : " cups");
  493. } else if (gallons < 1 / 2) {
  494. let volume = round(gallons * 8, 1);
  495. return volume + (singular || volume == 1 ? " pint" : " pints");
  496. } else if (gallons < 1) {
  497. let volume = round(gallons * 4, 1);
  498. return volume + (singular || volume == 1 ? " quart" : " quarts");
  499. } else if (gallons < 100) {
  500. let volume = round(gallons, 1);
  501. return volume + (singular || volume == 1 ? " gallon" : " gallons");
  502. } else {
  503. let volume = round(gallons, 0);
  504. return volume + (singular || volume == 1 ? " gallon" : " gallons");
  505. }
  506. }
  507. function customarySymVolume(m3, singular = false) {
  508. let gallons = m3 * 264.172;
  509. if (gallons < 1 / 16) {
  510. let volume = round(gallons * 128, 0);
  511. return volume + " fl oz";
  512. } else if (gallons < 1 / 4) {
  513. let volume = round(gallons * 16, 1);
  514. return volume + (singular || volume == 1 ? " cp" : " cps");
  515. } else if (gallons < 1 / 2) {
  516. let volume = round(gallons * 8, 1);
  517. return volume + " pt";
  518. } else if (gallons < 1) {
  519. let volume = round(gallons * 4, 1);
  520. return volume + " qt";
  521. } else if (gallons < 100) {
  522. let volume = round(gallons, 1);
  523. return volume + " g";
  524. } else {
  525. let volume = round(gallons, 0);
  526. return volume + " g";
  527. }
  528. }
  529. function approxVolume(m3, singular = false) {
  530. if (m3 < 2 / 10000) {
  531. let volume = round(m3 * 4e5, 0);
  532. return volume + (singular || volume == 1 ? " shot" : " shots");
  533. } else if (m3 < .1) {
  534. let volume = round(m3 * 2254, 1);
  535. return volume + (singular || volume == 1 ? " glass" : " glasses");
  536. } else if (m3 < 100) {
  537. let volume = round(m3 * 2.64, 1);
  538. return volume + (singular || volume == 1 ? " bathtub" : " bathtubs");
  539. } else if (m3 < 1e5) {
  540. let volume = round(m3 / 1000, 2);
  541. return volume + (singular || volume == 1 ? " Olympic swimming pool" : " Olympic swimming pools");
  542. } else if (m3 < 1e9) {
  543. let volume = round(m3 / 3.2e5, 2);
  544. return volume + (singular || volume == 1 ? " oil tanker" : " oil tankers");
  545. } else if (m3 < 1e15) {
  546. let volume = round(m3 / 1.8919e10, 3);
  547. return volume + (singular || volume == 1 ? " Great Salt Lake" : " Great Salt Lakes");
  548. } else if (m3 < 1e20) {
  549. let volume = round(m3 / 3.547e17, 3);
  550. return volume + (singular || volume == 1 ? " ocean" : " oceans");
  551. } else if (m3 < 1e25) {
  552. let volume = round(m3 / 1e21, 3);
  553. return volume + (singular || volume == 1 ? " Earth" : " Earths");
  554. } else {
  555. let volume = round(m3 / 1.4e27, 3);
  556. return volume + (singular || volume == 1 ? " Sun" : " Suns");
  557. }
  558. }
  559. function makeSphere(input = 0, diameter = false) {
  560. if (diameter = true) {
  561. input = input / 2;
  562. }
  563. return (4 / 3) * Math.PI * (Math.pow(input, 3));
  564. }
  565. function breakSphere(input = 0, diameter = false) {
  566. let output = math.pow((3 * input) / (4 * Math.PI), 1 / 3)
  567. if (diameter = true) {
  568. output = output * 2;
  569. }
  570. return output;
  571. }