[Vala] printing int64 value to standard output

2012-05-14 Thread D.H. Bahr
Hello there, how can I print an int64 variable to stdout??

int64 timestamp = 1234151912;
stdout.printf("%?", timestamp);

Best regards,
-- 

 Sw.E. D.H. Bahr
 Nova Desktop Development Leader
  CESOL (Free/Libre Software Centre)
UCI (University of Informatics Sciences)
Havana, Cuba




10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS 
INFORMATICAS...
CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION

http://www.uci.cu
http://www.facebook.com/universidad.uci
http://www.flickr.com/photos/universidad_uci
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] printing int64 value to standard output

2012-05-14 Thread Abhijit Hoskeri
On Mon, May 14, 2012 at 10:09 AM, D.H. Bahr  wrote:
> Hello there, how can I print an int64 variable to stdout??
>
> int64 timestamp = 1234151912;
> stdout.printf("%?", timestamp);
>

%lld is the format string you need.

Regards,
Abhijit
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] printing int64 value to standard output

2012-05-14 Thread D.H. Bahr
Thanks!!
El lun, 14-05-2012 a las 10:20 -0700, Abhijit Hoskeri escribió:
> On Mon, May 14, 2012 at 10:09 AM, D.H. Bahr  wrote:
> > Hello there, how can I print an int64 variable to stdout??
> >
> > int64 timestamp = 1234151912;
> > stdout.printf("%?", timestamp);
> >
> 
> %lld is the format string you need.
> 
> Regards,
> Abhijit
> 
> 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS 
> INFORMATICAS...
> CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION
> 
> http://www.uci.cu
> http://www.facebook.com/universidad.uci
> http://www.flickr.com/photos/universidad_uci

-- 

 Sw.E. D.H. Bahr
 Nova Desktop Development Leader
  CESOL (Free/Libre Software Centre)
UCI (University of Informatics Sciences)
Havana, Cuba




10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS 
INFORMATICAS...
CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION

http://www.uci.cu
http://www.facebook.com/universidad.uci
http://www.flickr.com/photos/universidad_uci
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] printing int64 value to standard output

2012-05-14 Thread jezra
On Mon, 14 May 2012 14:14:47 -0400
"D.H. Bahr"  wrote:

> Thanks!!
> El lun, 14-05-2012 a las 10:20 -0700, Abhijit Hoskeri escribió:
> > On Mon, May 14, 2012 at 10:09 AM, D.H. Bahr  wrote:
> > > Hello there, how can I print an int64 variable to stdout??
> > >
> > > int64 timestamp = 1234151912;
> > > stdout.printf("%?", timestamp);
> > >
> > 
> > %lld is the format string you need.
> > 
> > Regards,
> > Abhijit
> > 
> > 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS
> > INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION
> > 
> > http://www.uci.cu
> > http://www.facebook.com/universidad.uci
> > http://www.flickr.com/photos/universidad_uci
> 

Another option is to use Vala string templates:
int64 timestamp = 1234151912;
stdout.printf(@"$timestamp\n");

more examples of using string templates is available at:
http://live.gnome.org/Vala/StringSample
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] printing int64 value to standard output

2012-05-15 Thread pancake

%lld is not portable. your code will not work on windows.

the portable way is:

void main() {
uint64 ts = 123;
stdout.printf ("%"+uint64.FORMAT_MODIFIER;+"d\n", ts);
}


On 05/14/12 20:30, jezra wrote:

On Mon, 14 May 2012 14:14:47 -0400
"D.H. Bahr"  wrote:


Thanks!!
El lun, 14-05-2012 a las 10:20 -0700, Abhijit Hoskeri escribió:

On Mon, May 14, 2012 at 10:09 AM, D.H. Bahr  wrote:

Hello there, how can I print an int64 variable to stdout??

int64 timestamp = 1234151912;
stdout.printf("%?", timestamp);


%lld is the format string you need.

Regards,
Abhijit

10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS
INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION

http://www.uci.cu
http://www.facebook.com/universidad.uci
http://www.flickr.com/photos/universidad_uci

Another option is to use Vala string templates:
int64 timestamp = 1234151912;
stdout.printf(@"$timestamp\n");

more examples of using string templates is available at:
http://live.gnome.org/Vala/StringSample
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] printing int64 value to standard output

2012-05-15 Thread Sam Wilson

On 12-05-15 06:54 AM, pancake wrote:

%lld is not portable. your code will not work on windows.

the portable way is:

void main() {
uint64 ts = 123;
stdout.printf ("%"+uint64.FORMAT_MODIFIER;+"d\n", ts);
}


That just looks horrible... Couldn't Vala just compile %lld into the 
proper format on each platform?


Sam




smime.p7s
Description: S/MIME Cryptographic Signature
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] printing int64 value to standard output

2012-05-15 Thread pancake

On 05/15/12 14:43, Sam Wilson wrote:

On 12-05-15 06:54 AM, pancake wrote:

%lld is not portable. your code will not work on windows.

the portable way is:

void main() {
uint64 ts = 123;
stdout.printf ("%"+uint64.FORMAT_MODIFIER;+"d\n", ts);
}


That just looks horrible... Couldn't Vala just compile %lld into the 
proper format on each platform?


Sam



i know :) but that's just up to the GLIB library, not the C standard. 
you can use an const string somewhere like:


const string U64FMTd = "%"+uint64.FORMAT_MODIFIER+"d";

But I agree.. glib should provide a format string modifier for this 
instead of providing defines for using them.

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] printing int64 value to standard output

2012-05-15 Thread Aaron

Just use string templates:

stdout.printf (@"$ts\n");

String templates will always give you the proper format.

Aaron

Quoting Sam Wilson :


On 12-05-15 06:54 AM, pancake wrote:

%lld is not portable. your code will not work on windows.

the portable way is:

void main() {
uint64 ts = 123;
stdout.printf ("%"+uint64.FORMAT_MODIFIER;+"d\n", ts);
}


That just looks horrible... Couldn't Vala just compile %lld into the  
proper format on each platform?


Sam






___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list