Ok, the value stored in int type variable is correct (I mean 12) but try the following code :
void main() { int64 val6 = 96; int val7 = (int) (val6 / 8); stdout.printf ("val6: %lld, val7 : %d\n", val6, val7); stdout.printf ("%d\n", val7); } output : $ a val6: 96, val7 : 0 12 Int64 is correctly disdplayed with "%lld" format, int is not correctly displayed at first. Strange ? isn'it ? :) But ok, I've got the right value. generated C code : /* a.c generated by valac 0.20.1, the Vala compiler * generated from a.vala, do not modify */ #include <glib.h> #include <glib-object.h> #include <stdio.h> void _vala_main (void); void _vala_main (void) { gint64 val6; gint val7; FILE* _tmp0_; FILE* _tmp1_; val6 = (gint64) 96; val7 = (gint) (val6 / 8); _tmp0_ = stdout; fprintf (_tmp0_, "val6: %lld, val7 : %d\n", val6, val7); _tmp1_ = stdout; fprintf (_tmp1_, "this is correct : %d\n", val7); } int main (int argc, char ** argv) { g_type_init (); _vala_main (); return 0; } > not for me > > On 07/31/13 10:27, r...@no-log.org wrote: >> int64 val6 = 96; >> int val7 = (int) (val6 / 8); > > $ cat a.vala > void main() { > int64 val6 = 96; > int val7 = (int) (val6 / 8); > stdout.printf ("%d\n", val7); > } > $ vala a.vala > 12 > > If you use the wrong format string you are going to display wrong data. > > This is, windows is 32bit, and values are pushed on the stack from 4 > bytes to 4, if the printf format expects a 64bit value it will fetch 4 > bytes from the value and 4 bytes more from the stack (which can be zero > or any other value) causing the output you see. > > Please, use the proper format string. > > You can see the C code to verify if the compiler does it right, but you > didnt provided the valac version and I doubt vala can do such a simple > operation wrong. > > --pancake > _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list