Modulo:BaseConvert/man

Questo modulo serve a...


Questo modulo serve a...

Converte i numeri in specifiche basi tra 2 e 36, da usare in template come {{binario}}, {{ottale}}, {{esadecimale}}, ecc.

Esempio d'uso:

local BaseConvert = require('Module:BaseConvert')
BaseConvert.convert({n = 14600926, base = 16}) -- restituisce 'DECADE'
-- o, se usato una sola volta,
local BaseConvert = require('Module:BaseConvert').convert({n = 14600926, base = 16}) -- restituisce 'DECADE'

Argomenti:

  • n - (richiesto) il numero da convertire, come una stringa. Deve essere un numero, se la base dell'input input è 10.
  • base - (richiesto) la base a cui il numero dev'essere convertito. Può essere tra 2 e 36, estremi inclusi.
  • from - la base dell'input. Preimpostata a 10 (o 16 se l'input ha prefisso '0x'). Notare che per basi diverse da 10 non sono supportati input con parte frazionale.
  • precision - numero di cifre decimali da mostrare a destra della virgola. Se non specificato, saranno mostrate fino a 10 cifre.
  • width - minimo numero di cifre non decimali da mostrare a sinistra della virgola. Gli zeri iniziali vengono aggiunti se necessari.
  • default - Valore da restituire se n è vuoto o non numerico. Per impostazioni predefinite è il valore di n.
  • prefix / suffix - wikitesto da aggiungere a sinistra/destra il risultato. Non sarà aggiunto se n è vuoto o non numerico. Per esempio, devi usare il prefisso 0x quando converti ad hex, od il suffisso <sub>8</sub> quando converti ad ottale.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.