Sapere il tipo di dato più piccolo in Gambas capace di contenere e rappresentare un numero
Da Gambas-it.org - Wikipedia.
Versione del 9 dic 2021 alle 18:51 di Vuott (Discussione | contributi) (Creata pagina con "Per sapere il tipo di dato più piccolo in Gambas capace di contenere e rappresentare un numero, si può adottare il seguente codice: Private Const NUMERO As Long = 21081969...")
Per sapere il tipo di dato più piccolo in Gambas capace di contenere e rappresentare un numero, si può adottare il seguente codice:
Private Const NUMERO As Long = 21081969 ' Il numero da verificare Public Sub Main() Dim n, t, s As String Dim b As Byte n = "1" t = "BYTE" If NUMERO < 0 Then n = "0" t = "SHORT" Endif Print Bin(NUMERO, 64) b = InStr(Bin(NUMERO, 64), n) s = "LONG" If b > 33 Then s = "INTEGER" If b > 49 Then s = "SHORT" If (b == 0) Or (b > 56) Then s = t Print "\nIn Gambas il numero \e[31m"; CStr(NUMERO); "\e[0m può essere contenuto da un dato di tipo: \e[31m"; s End