¿Cómo escribir códigos binarios, octales, decimales y hexadecimales en Easy Language?
Código fuente sencillo. Versión 2. Subrutina 10 a 2, tipo de texto, abre, convierte decimal a binario (devuelve texto binario).
Número decimal del parámetro, tipo entero, número decimal a convertir.
Texto de variable local, tipo de texto
. La variable local devuelve texto, tipo de texto. Determine el encabezado del bucle (número decimal > 0).
Texto = texto + carácter (código (" 0 ",) + número decimal % 2)
Decimal = número decimal ÷ 2
. Determine el final del bucle ()
. Contar encabezado de bucle (obtener longitud del texto (texto), número decimal)
Devolver texto = devolver texto + obtener texto medio (texto, obtener longitud del texto (texto) - número decimal + 1, 1)
. Return()(devuelve texto) al final del bucle