HP Forums
[HP Prime]Program to count bits - word - binary [New app] - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: [HP Prime]Program to count bits - word - binary [New app] (/thread-18865.html)



[HP Prime]Program to count bits - word - binary [New app] - DrEureka - 09-23-2022 05:50 AM

Hello I leave this program I hope you will use whoever wants to use it, I am new in the PPL programming, apologize if there are better ways to improve the code.
[Image: ingreso-programa.HaAfY]
https://tinypic.host/i/ingreso-programa.HaAfY
Code:

//DrEureka Wbinary Ver. 0.0.1


EXPORT WBINARIO()
BEGIN
LOCAL Wo;
LOCAL Ra;
LOCAL Rb;
PRINT();
INPUT({
{Wo,[0],{50,30,1}} 
},
"WORD BINARIO", 
{"CANTIDAD N°:"}, 
{"Ingresar simbolo y magnitud"});
//Input por orden!
//variable + tipo de ingreso 0 es real + ancho del input nombre y ancho del ingreso + posicion puede ser de 0 a 6 para la primera pantalla y sucesivo.
//titulo de la app
//etiqueta del input
//ayuda en el casillero del input
IF Wo==0 THEN
        MSGBOX("ERROR:error de sintaxis. El valor no puede ser 0");
        KILL;
    END;

Ra:=(2^(Wo-1))-1;
Rb:=(2^(Wo-1));
PRINT("****RESULTADO****");
PRINT("");
PRINT("Valor ingresado: "+Wo);
PRINT("Cuenta para max positivos: (2^("+Wo+"-1))-1");
PRINT("Cuenta para max negativos: (2^("+Wo+"-1))");
PRINT("");
PRINT("POSITIVO MAX=+"+Ra);
PRINT("NEGATIVO MAX=-"+Rb);
WAIT(-1);
MSGBOX("Programa finalizado");
END;



RE: Program to count bits - word - binary - Didier Lachieze - 09-23-2022 12:38 PM

I’ve tried your program but found that LGVarNum is not defined which creates a syntax error.
Also can you provide some usage examples with input values and expected output results?


RE: Program to count bits - word - binary - DrEureka - 09-23-2022 03:06 PM

(09-23-2022 12:38 PM)Didier Lachieze Wrote:  I’ve tried your program but found that LGVarNum is not defined which creates a syntax error.
Also can you provide some usage examples with input values and expected output results?

Hello, it has already been solved, as an example:

if the first binary sign is 0 it is positive if it is 1 it is negative, and it gives you the maximum that covers the number of bits according to the input, for example if there are 4 digits you can set between +15 and -16.
Thank you for your review, it helps me to continue improving.