GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Aug 21, 2014 12:24 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: conversion of gint16 to gint
PostPosted: Fri Nov 03, 2006 12:21 pm 
Offline
Familiar Face

Joined: Wed Oct 11, 2006 9:49 am
Posts: 10
iam new ti GTK
please tell me
conversion of gint16 to gint.
thank u in advance
raj


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 1:41 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
You will want to check out the G_*_FORMAT macros here: http://developer.gnome.org/doc/API/2.0/ ... ORMAT:CAPS

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject: thanku
PostPosted: Sat Nov 04, 2006 4:18 am 
Offline
Familiar Face

Joined: Wed Oct 11, 2006 9:49 am
Posts: 10
but here no G_GINT_FORMAT
then how can i convert gint16 to gint .


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 04, 2006 4:54 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
I haven't tested it, but you should be able to do:

Code:
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 ...

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 4:23 am 
Offline
Familiar Face

Joined: Wed Oct 11, 2006 9:49 am
Posts: 10
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 4:36 am 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Well, you just have to look at the bounds as defined on: http://developer.gnome.org/doc/API/2.0/ ... .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:
gint red = (gint) color.red;

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject: i got it
PostPosted: Mon Nov 13, 2006 4:21 am 
Offline
Familiar Face

Joined: Wed Oct 11, 2006 9:49 am
Posts: 10
finally done this
by simply dividing the gint16 number with 256 to get the gint value


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group