|     |    
	
		
			
			
				
					
						|   
							 
								if you want to make any kind of calculator...   | 
							    |      |      |                      |           Submitted on: 11/23/2003 9:52:41 AM 
						By: Bryant Zadegan  
						 
						Level: Beginner User Rating: Unrated   Compatibility:VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0, VB Script, ASP (Active Server Pages) , VBA MS Access, VBA MS Excel
  Users have accessed this article 300 times.   |  (About the author) |  
  |          |   |                 DONT VOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!
this is simply to help the person who wants to make his furst good program         |    |  |   |              Terms of Agreement:    
	 By using this article, you agree to the following terms...    
	 1) You may use 
	 this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.    
	 2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.    
	 3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.  
	 4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.   |  I looked at the microsoft calculator today and entered the command 0^0 (zero to the zero power), and the response i got was astonishing! last i checked, 0^0 is undefined. The Microsoft calc sed it was one!.
i later hacked the calculator open and, as no surprise, discovered a simple if-then statement was responsible.
the statement very simply sed: 
(actual control names not used)
(All names of subs and functions simulated)
If lblDisp.caption="0" then
    .....
    If xUPy = true then call finResult(1)
    .....
End If
 What it SHOULD HAVE BEEN:
call doMicrosoftMath (x, y, toPower)
or it could have been:
If lblDisp.caption="0" then
    .....
    If xUPy = true then
        If x = 0 and y = 0 then
            Call finResult(Undefined!)
        Else
            call finResult(1)
        End If
     End If
     .....
End If
 What am i trying to say? If youre going to make a calculator that takes x to the y power, make sure that 0^0 is undefined! otherwise, your calculators will be criticized the way I laid microsoft down just now!
also, use common sense have the calculator actually DO THE MATH rather than follow wimpy if-then statements!!!!!
for those of you that dont know how to do the topower thing, watch:
Function ToPower(num1 As Long, num2 As Long) As Long
     'Bring num1 to the power (exponent) of n
    '     um2
    On Error GoTo error
    ToPower = Val(num1) ^ Val(num2)
    Exit Function
    error: MsgBox Err.Description, vbExclamation, "Error"
End Function
 --excerpt from Infrared's source.bas
math is done here: x^y where the ^ is the actual operator. to call, type:
call ToPower (x,y)
where x is the number and y is the power.
to end the article i will reinforce one thing:
DDOONNTT VVOOTTEE!!!!!! |    |     Other 2 submission(s) by this author
  |     |    |   |  | Report Bad Submission |     |   |   |  | Your Vote! |  | 
See Voting Log  |  |   |  | Other User Comments |  11/23/2003 3:29:46 PM:  What are you talking about?? My Win2k 
calc says its undefined:
Result of 
function is undefined.
Since you 
said dont vote, you get 0^0 globes.  
  |  11/23/2003 4:52:59 PM:Bryant Zadegan im using windows xp  
  |  11/23/2003 4:55:35 PM:Bryant Zadegan also, as a side note, change the 
calculator format to scientific, and 
hit the x^y button  
  |   |      |   Add Your Feedback! |        Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.
  NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.
  For feedback not related to this particular article, please click here.     |       |           |