[Vala] Why is 77 greater than 4294967295?
- From: Jason Martin <agrellum gmail com>
- To: vala-list gnome org
- Subject: [Vala] Why is 77 greater than 4294967295?
- Date: Thu, 22 Nov 2018 22:33:19 -0500
// simple vala code
void main () {
long i = 77;
stdout.printf ("%ld\n", i);
// outputs 77
stdout.printf ("%u\n", uint.MIN);
// outputs 0
if (i < uint.MIN) {
stdout.printf ("Never made it here.\n");
}
stdout.printf ("%u\n", uint.MAX);
// outputs 4294967295
// G_MAXUINT
if (i > uint.MAX) {
stdout.printf ("Why am I here.\n");
}
}
valac --cc=gcc gbug.vala
C code generated
/* gbug.c generated by valac 0.40.11, the Vala compiler
* generated from gbug.vala, do not modify */
#include <glib.h>
#include <glib-object.h>
#include <stdio.h>
void _vala_main (void);
void
_vala_main (void)
{
glong i = 0L;
FILE* _tmp0_;
glong _tmp1_;
FILE* _tmp2_;
glong _tmp3_;
FILE* _tmp5_;
glong _tmp6_;
i = (glong) 77;
_tmp0_ = stdout;
_tmp1_ = i;
fprintf (_tmp0_, "%ld\n", _tmp1_);
_tmp2_ = stdout;
fprintf (_tmp2_, "%u\n", 0);
_tmp3_ = i;
if (_tmp3_ < ((glong) 0)) {
FILE* _tmp4_;
_tmp4_ = stdout;
fprintf (_tmp4_, "Never made it here.\n");
}
_tmp5_ = stdout;
fprintf (_tmp5_, "%u\n", G_MAXUINT);
_tmp6_ = i;
if (_tmp6_ > ((glong) G_MAXUINT)) {
FILE* _tmp7_;
_tmp7_ = stdout;
fprintf (_tmp7_, "Why am I here.\n");
}
}
int
main (int argc,
char ** argv)
{
_vala_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]