|
|
| Author |
Message |
|
|
raj4u Familiar Face
Joined: 11 Oct 2006 Posts: 10
|
Posted: Fri Nov 03, 2006 12:21 pm Post subject: conversion of gint16 to gint |
|
|
iam new ti GTK
please tell me
conversion of gint16 to gint.
thank u in advance
raj |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
|
| Back to top |
|
 |
raj4u Familiar Face
Joined: 11 Oct 2006 Posts: 10
|
Posted: Sat Nov 04, 2006 4:18 am Post subject: thanku |
|
|
but here no G_GINT_FORMAT
then how can i convert gint16 to gint . |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Sat Nov 04, 2006 4:54 pm Post subject: |
|
|
I haven't tested it, but you should be able to do:
| Code: (Plaintext) | 1 2 3 4
| gint x;
gint16 y;
x = (gint) y; |
The only problem with that is you have to make sure that your gint16 isn't out of bounds ... |
|
| Back to top |
|
 |
raj4u Familiar Face
Joined: 11 Oct 2006 Posts: 10
|
Posted: Mon Nov 06, 2006 4:23 am Post subject: |
|
|
actually wht i need is suppose i have gdkcolor *collor="#FFFFFF";
from iiam geting the values of red ,blue green by usiing color.red,color.green,color.blue,
all these r gint16 variables.
so i want to convert it into gint.
suppose from the above
red==255, like this |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Mon Nov 06, 2006 4:36 am Post subject: |
|
|
Well, you just have to look at the bounds as defined on: http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html#gint
gint16 is defined as a short integer, which is 16 bits. gint is an integer, which is 32 bits.
Therefore, you should be able to cast in the same way as you would in C:
| Code: (Plaintext) | 1
| gint red = (gint) color.red; | |
|
| Back to top |
|
 |
raj4u Familiar Face
Joined: 11 Oct 2006 Posts: 10
|
Posted: Mon Nov 13, 2006 4:21 am Post subject: i got it |
|
|
finally done this
by simply dividing the gint16 number with 256 to get the gint value |
|
| Back to top |
|
 |
|