CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

printf int32

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

printf int32
PostPosted: Tue Feb 21, 2023 5:38 pm     Reply with quote

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: 19539

View user's profile Send private message

PostPosted: Wed Feb 22, 2023 2:22 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 22, 2023 3:37 pm     Reply with quote

my version is 5.101
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Thu Feb 23, 2023 2:55 am     Reply with quote

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).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group