| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| nailuy 
 
 
 Joined: 21 Sep 2010
 Posts: 159
 
 
 
			    
 
 | 
			
				| printf int32 |  
				|  Posted: Tue Feb 21, 2023 5:38 pm |   |  
				| 
 |  
				| how to print long long (double) or int32? 
 
  	  | Code: |  	  | int32 test =  16777215 
 printf("%Lu", test);
 | 
 
 resoult is 65535.
 
 how to print value larger than 65535?
 
 not help %9Lu
 and
 is not working %LLu
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Feb 22, 2023 2:22 am |   |  
				| 
 |  
				| What compiler version do you have?. %Lu should print this fine, provided the value genuinely is an int32.
 
 Some of the very early V4 compilers had problems with int32 (about 4.119
 I think).
 |  | 
	
		|  | 
	
		| nailuy 
 
 
 Joined: 21 Sep 2010
 Posts: 159
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Feb 22, 2023 3:37 pm |   |  
				| 
 |  
				| my version is 5.101 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Feb 23, 2023 2:55 am |   |  
				| 
 |  
				| I've just built a test with 5.101, and a PIC18F2420. Merrily works:
 
  	  | Code: |  	  | #include <18F2420.h>
 #device ADC=10
 
 #FUSES NOWDT
 
 #use delay(crystal=20000000)
 #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)
 
 void main()
 {
 int32 test =  16777215;
 setup_adc_ports(NO_ANALOGS, VSS_VDD);
 
 printf("%Lu", test);
 
 while(TRUE)
 {
 delay_cycles(1);
 }
 }
 
 | 
 
 Outputs to the terminal : 16777215
 
 This on a basic MicroChip prototype board (20MHz crystal).
 |  | 
	
		|  | 
	
		|  |