cdf =Manipulate[Column[{ Calcule[x, k, n1, n2, tipo]}],Style[proposito,Bold,10],Spacer[{100,3}],
{{x,126.652877, "Número a convertir  x ="}},{{k,3, "Número de dígitos  k ="}},{{n1,-4, "Mínimo exponente  (Subscript[n, 1]) ="}},{{n2,4, "Máximo exponente  (Subscript[n, 2]) ="}},
{{tipo,1,"Escoger:"},{1->"Truncamiento a k dígitos",2->"Redondeo a k dígitos"},
ControlType->RadioButtonBar},Button["OK"],Alignment->Center,Deployed->True,AppearanceElements->"ResetButton",LocalizeVariables->True,ContinuousAction->False,FrameLabel->{{None,None},{Column[{,Row[{Style["Autores: Juan Félix Ávila Herrera y Enrique Vílchez Quesada",Bold,10,RGBColor[0,0,0.5]]}],Row[{Style["Escuela de Informática | Universidad Nacional de Costa Rica",Bold,10,RGBColor[0.5,0.1,0]]}]},Center],Style["Título: Covertirdor a punto flotante. ", Bold,14, RGBColor[0,0.33,0.33]]}},Initialization:>(
proposito ="Propósito: Redondeo y truncamiento de números en un conjunto F(k, n1, n2) ";
Calcule[x_, k_, n1_, n2_, tipo_] :=Module[{aux, truncado, pararedondeo, xx, tome, signo, losdigitos, exponente},
$PreRead=(#/. s_String/;StringMatchQ[s,NumberString]&&Precision@ToExpression@s==MachinePrecision:>s<>"`12."&);
losdigitos[xx_] := Module[{y},y=MantissaExponent[N[Abs[xx]]][[1]];
While[y≠Round[y], y=y*10]; 
{IntegerDigits[Round[y]] , 0}

]; 
signo[xx_] := If[xx≥0, "", "-"];
tome[v_, kk_] := Module[{lista =v}, 
 While[Length@lista<kk, lista =Append[lista, 0]];
Take[lista, kk]
  ];
aux =FromDigits[tome[losdigitos[x][[1]], k]] /10.^k;
exponente=MantissaExponent[N[x]][[2]];
If[exponente >n2,  Return[ "Alerta: Overflow"]];
If[0<Abs[x] <10^n1,  Return[ "Underflow. Se asigna 0"]];
If[x==0,  Return[ "0"]];
truncado = signo[x]<>ToString@aux<>" * 10^"<>ToString@exponente; 
If[tipo==1,truncado<>"=\n"<>ToString[DecimalForm[ToExpression[truncado], k+1]], 
pararedondeo =tome[losdigitos[x][[1]], k+1];
If[pararedondeo[[-1]] <5,truncado,
 xx=Sign[x]*( Abs@x+5*10^(exponente-k-1));
aux =FromDigits[tome[losdigitos[xx][[1]], k]] /10.^k;
exponente=MantissaExponent[N[xx]][[2]];
truncado =signo[x]<>ToString@aux<>" * 10^"<>ToString@exponente;
truncado<>"=\n"<>ToString[DecimalForm[ToExpression[truncado], k+1]]
]

]]
)]