[ros-dev] Re: [ros-bugs] [Bug 1149] Calculator bug

Jerry crashfourit at gmail.com
Sun Dec 18 06:17:20 CET 2005


I think I got it fixed. Hear's the diff:

Index: subsys/system/calc/winecalc.c
===================================================================
--- subsys/system/calc/winecalc.c    (revision 20239)
+++ subsys/system/calc/winecalc.c    (working copy)
@@ -755,32 +755,34 @@
             {
                 int i;
                 int w = LOWORD(wParam);
+                int Base;
+                calcfloat r;
+               
+                r = calc_atof(calc.buffer, calc.numBase);
 
                 if (w == ID_CALC_NS_HEX) {
-                    if (calc.numBase == NBASE_HEX)
-                        return 0;
-                    else
-                        calc.numBase = NBASE_HEX;
+                    Base = NBASE_HEX;
                 }
                 else if (w == ID_CALC_NS_DEC) {
-                    if (calc.numBase == NBASE_DECIMAL)
-                        return 0;
-                    else
-                        calc.numBase = NBASE_DECIMAL;
+                    Base = NBASE_DECIMAL;
+                   
                 }
                 else if (w == ID_CALC_NS_OCT) {
-                    if (calc.numBase == NBASE_OCTAL)
-                        return 0;
-                    else
-                        calc.numBase = NBASE_OCTAL;
+                    Base = NBASE_OCTAL;
                 }
                 else if (w == ID_CALC_NS_BIN) {
-                    if (calc.numBase == NBASE_BINARY)
+                    Base = NBASE_BINARY;
+                }
+               
+                if (calc.numBase == Base){
                         return 0;
-                    else
-                        calc.numBase = NBASE_BINARY;
+                } else {
+                        calc.numBase = Base;
                 }
+               
+                calc_ftoa(&calc, r, calc.buffer);
 
+
                 for (i=0;i<CALC_NS_COUNT;i++)
                     SendMessage(calc.cb[60+i].hBtn, BM_SETCHECK, w == 
(ID_CALC_NS_HEX + i) ? 1 : 0, 0);
 
@@ -2944,16 +2946,23 @@
 
     switch (calc->numBase) {
     case NBASE_HEX:
-        real = calc_atof(calc->buffer, calc->numBase);
-        _stprintf(calc->display, TEXT("%lx"), (long)real);
+        //real = calc_atof(calc->buffer, calc->numBase);
+        //_stprintf(calc->display, TEXT("%lx"), (long)real);
+        //_stprintf(calc->display, TEXT("%lX"), calc->buffer);
+        _stprintf(calc->display, TEXT("%s"), calc->buffer);
         break;
 
     case NBASE_OCTAL:
-        _stprintf(calc->display, TEXT("%lo"), (long)calc->buffer);
+        //real = calc_atof(calc->buffer, calc->numBase);
+        //_stprintf(calc->display, TEXT("%lo"), (long)real);
+        //_stprintf(calc->display, TEXT("%lo"), (long)calc->buffer);
+        _stprintf(calc->display, TEXT("%s"), calc->buffer);
         break;
 
     case NBASE_BINARY:
-        _stprintf(calc->display, TEXT("%lx"), (long)calc->buffer);
+       
+        //_stprintf(calc->display, TEXT("%lx"), (long)calc->buffer);
+        _stprintf(calc->display, TEXT("%s"), calc->buffer);
         break;
 
     case NBASE_DECIMAL:
@@ -3229,8 +3238,15 @@
     case NBASE_OCTAL:
         _stprintf(buf, TEXT("%lo"), (long)r);
         break;
-    case NBASE_BINARY: // 911 - need routine here
-
+    case NBASE_BINARY: // 911 - need routine here
+        {
+          int x;
+          for(x=0; x < sizeof(calcfloat); x++){
+             if (( (long)r & (1<<( (sizeof(calcfloat)-1) -x ))) == 1<<( 
(sizeof(calcfloat)-1) -x ) ) buf[x] = '1'; else buf[x] = '0'; 
+                 
+          };
+          buf[sizeof(calcfloat)]='\0';
+        }
         break;
     default:
         break;


/* End of Diff */

Tell me if it works or not, please. Thanks.

ReactOS.Bugzilla at reactos.org wrote:

>http://www.reactos.org/bugzilla/show_bug.cgi?id=1149
>
>
>
>
>
>------- Additional Comments From crashfourit at gmail.com  2005-12-18 05:27 CET -------
>No, I hadd the same problem in WinXP. I'm in the process of fixing it.
>
>  
>



More information about the Ros-dev mailing list