Re: [Vala] Int64 operations, I'm confused



My problem is not how to ouput an int64 but I need to divide a int64 by 8
and store the result in int type...

      int64 val6 = 96;
      int val7 = (int) (val6 / 8);

val7 = 0 ? Why ?

$ test
val1: 96, val2 : 0
val4: 96, val5 : 12
val6: 96, val7 : 0
$

Thanks

You can also use int64.FORMAT like this:

stdout.printf ("val1: "+int64.FORMAT+"\n", val1);

This is because stdout.printf is using libc's fprintf function, instead
of the glib one. The windows libc uses the %I64d" format instead of
%lld, so it fails.

Use the portable way instead, or just use glib format functions only.

On 07/30/13 16:57, Simon Kågedal Reimer wrote:
The problem is that %lld doesn't work at all on Windows. Read the
e-mail Steven linked to again. :) You could try the following:

void main () {
     int64 val1 = 96;
     int64 val2 = val1 / 8;
     stdout.printf (@"val1: $val1, val2: $val2\n");

     int val4 = 96;
     int val5 = val4 / 8;
     stdout.printf (@"val4: $val4, val5: $val5\n");

     int64 val6 = 96;
     int val7 = (int) (val6 / 8);
     stdout.printf (@"val6: $val6, val7: $val7\n");
}
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list


_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]