Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: size of a datatype

  • Subject: Re: size of a datatype
  • From: Roy Schestowitz <newsgroups@xxxxxxxxxxxxxxx>
  • Date: Sat, 13 May 2006 16:04:16 +0100
  • Newsgroups: comp.os.linux.advocacy
  • Organization: schestowitz.com / MCC / Manchester University
  • References: <1147499965.060218.303410@i40g2000cwc.googlegroups.com> <40egj3-uju.ln1@ridcully.fsnet.co.uk> <1147506449.314246.192970@j73g2000cwa.googlegroups.com>
  • Reply-to: newsgroups@xxxxxxxxxxxxxxx
  • User-agent: KNode/0.7.2
__/ [ sonu ] on Saturday 13 May 2006 08:47 \__

> spike1@xxxxxxxxxxxxx wrote:
>> sonu <sanjaykumar.barick@xxxxxxxxx> did eloquently scribble:
>>
>> > Hi All,
>>
>> > i am using Suse(Novell Linux Desktop). here i wants to store a data
>> > 0xffffffffffffffff what is the data type . i used guint64. please help
>> > i need urgent
>>
>> 1: Wrong newsgroup. This is where you come when you want to get insulted
>> by wintrolls or flame them in return. You want one of the development
>> groups. comp.os.linux.development.apps is probably ideal.


Yes, but help can be found in this group as well. 


>> 2: You need to word your quesion better. Because I don't see what you need
>> help with. It seems like you already have a type that's the correct,
>> unsigned 64bit integer.
>>
>> 3: What's so urgent about it? Homework assignment late?


*LOL* A classic, that one.


> i wrote like
> main()
> {
>  guint64 x=0xffffffffffffffff
> 
> printf("%15d",x);
> }
> 
> But it is showing warning integer constant is too large for  "long"
> type


You  are mixing two different datatypes in a very obscure and unsafe  way.
Ultimately,  if you do not study printf specifiers, your code will  become
unreliable  and  prone to breakage at edge cases (e.g. large numbers  with
incompatible types have different boundaries). In this simplified example,
you  assign a value which is hexadecimal, but print it as decimal. I don't
know  what  you are trying to achieve, but this mishmash is a  recipe  for
unreliable  code. GCC is giving you a _good and much-appreciated_  warning
there!  It would do the same for string-numeric mishmash, so never  ignore
or suppress the warnings.

Best wishes,

Roy

-- 
Roy S. Schestowitz      |    "Seeing bad movies only encourages them"
http://Schestowitz.com  |  Open Prospects   ¦     PGP-Key: 0x74572E8E
  3:55pm  up 15 days 22:52,  12 users,  load average: 0.95, 0.73, 0.57
      http://iuron.com - knowledge engine, not a search engine

[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index