howard
howard

Reputation: 55

Ghashtable storing double

Hello I was wondering if it was possible to store a double into a ghashtable considering there is no gdouble_to_pointer methdod. I am following a tutorial I found online by IBM http://www.ibm.com/developerworks/linux/tutorials/l-glib/section5.html , but I can't seem to find a way to use an int as a key and a double as the value being stored. Any help would be great thanks!

Upvotes: 2

Views: 698

Answers (1)

jstedfast
jstedfast

Reputation: 38593

If you want to use an int as a key, you should use g_int_hash() and g_int_equal() when you create the GHashTable.

As far as using doubles for values goes... you can't. The problem is that you cannot guarantee that sizeof (void *) >= sizeof (double), so you can't use a trick like GINT_TO_POINTER()

Upvotes: 2

Related Questions