2 * Types utility routines
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "type_util.h"
16 * guint64 to gdouble conversions taken from gstutils.c of GStreamer project
19 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
20 * 2000 Wim Taymans <wtay@chello.be>
21 * 2002 Thomas Vander Stichele <thomas@apestaart.org>
23 * gstutils.h: Header for various utility functions
29 /* work around error C2520: conversion from unsigned __int64 to double
30 * not implemented, use signed __int64
32 * These are implemented as functions because on some platforms a 64bit int to
33 * double conversion is not defined/implemented.
37 type_util_guint64_to_gdouble(guint64 value)
39 if (value & G_GUINT64_CONSTANT (0x8000000000000000))
40 return (gdouble) ((gint64) value) + (gdouble) 18446744073709551616.;
42 return (gdouble) ((gint64) value);
46 type_util_gdouble_to_guint64(gdouble value)
48 if (value < (gdouble) 9223372036854775808.) /* 1 << 63 */
49 return ((guint64) ((gint64) value));
51 value -= (gdouble) 18446744073709551616.;
52 return ((guint64) ((gint64) value));
56 * Editor modelines - https://www.wireshark.org/tools/modelines.html
61 * indent-tabs-mode: nil
64 * ex: set shiftwidth=2 tabstop=8 expandtab:
65 * :indentSize=2:tabSize=8:noTabs=true: