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



not for me

On 07/31/13 10:27, raum 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


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