Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/11/05 11:14
Read: times


 
#84737 - Exactly what it says on the tin!
Responding to: ???'s previous message
Rob Woodhouse said:
when i use:
printf("%dn",totcount);
it gives an answer of -4352

It is doing exactly what you asked it to do, as clearly stated in the Keil Manual:
From p291 of the Keil C51 Manual, 09.2001 - click to go to the online version
(Note that this is standard 'C' - any other compiler would do the same).

That's why I said to you before,
I said:
If you are using printf, are you sure that you have used the correct unsigned format specifier?

Remember, computers are totally stupid things - they will do exactly what you say; they will not attempt to work out what you mean!

You told it, "print the supplied value as a signed int" - so that's what it did!

List of 23 messages in thread
TopicAuthorDate
Multiplication Problems and data types            01/01/70 00:00      
   use unsigned int for totcount            01/01/70 00:00      
   Wrong printf format specifier?            01/01/70 00:00      
      yes i am using printf            01/01/70 00:00      
         manual!            01/01/70 00:00      
            using %d and %x            01/01/70 00:00      
               %u            01/01/70 00:00      
               Exactly what it says on the tin!            01/01/70 00:00      
                  Division problem?            01/01/70 00:00      
   division problem in keil evaluation?            01/01/70 00:00      
      Which Part?            01/01/70 00:00      
      its ok i have sorted it!            01/01/70 00:00      
         Still a problem, then...            01/01/70 00:00      
         not so strange            01/01/70 00:00      
            Not so strange?            01/01/70 00:00      
      Need complete code!            01/01/70 00:00      
         Like this            01/01/70 00:00      
         code            01/01/70 00:00      
            Calling printf from an ISR            01/01/70 00:00      
               other interrupts wont get in the way            01/01/70 00:00      
                  ISR            01/01/70 00:00      
                     yes i see what you mean            01/01/70 00:00      
                  No No Inside ISR            01/01/70 00:00      

Back to Subject List