GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

conversion of gint16 to gint

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
raj4u
Familiar Face


Joined: 11 Oct 2006
Posts: 10

PostPosted: Fri Nov 03, 2006 12:21 pm    Post subject: conversion of gint16 to gint Reply with quote

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

PostPosted: Fri Nov 03, 2006 1:41 pm    Post subject: Reply with quote

You will want to check out the G_*_FORMAT macros here: http://developer.gnome.org/doc/API/2.0/glib/glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS
Back to top
raj4u
Familiar Face


Joined: 11 Oct 2006
Posts: 10

PostPosted: Sat Nov 04, 2006 4:18 am    Post subject: thanku Reply with quote

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

PostPosted: Sat Nov 04, 2006 4:54 pm    Post subject: Reply with quote

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

PostPosted: Mon Nov 06, 2006 4:23 am    Post subject: Reply with quote

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

PostPosted: Mon Nov 06, 2006 4:36 am    Post subject: Reply with quote

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

PostPosted: Mon Nov 13, 2006 4:21 am    Post subject: i got it Reply with quote

finally done this
by simply dividing the gint16 number with 256 to get the gint value
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP