473,396 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

UnSigned Long

Hi,

I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.
I am using MSVC++ 6.0

Any help please urgent....

Thanks
J.
Nov 15 '05 #1
9 2489
Joriveek wrote:
Hi,

I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.
Please provide some more information (for example a small example
program showing your problem together with the output of this program).
I am using MSVC++ 6.0
Some people are lucky, others are not.....

Kind regards,
Johan

--
o o o o o o o . . . _____J_o_h_a_n___B_o_r_k_h_u_i_s___
o _____ || http://www.borkhuis.com |
.][__n_n_|DD[ ====_____ | jo***@borkhuis.com |(________|__|_[_________]_|________________________________|

_/oo OOOOO oo` ooo ooo 'o!o!o o!o!o`
== VxWorks FAQ: http://www.xs4all.nl/~borkhuis/vxworks/vxworks.html ==
Nov 15 '05 #2
Joriveek wrote:
Hi,

I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.
#include <stdio.h>

int main(void)
{
unsigned int myvarz = 3000000000;
printf("%u\n",myvarz);
return 0;
}
This is working in msvc++ 6.0 and gcc.Please post your code

Johan Borkhuis wrote: Some people are lucky, others are not.....

very true.

Nov 15 '05 #3

"Joriveek" <no****@please.com> wrote in message
news:de**********@reader01.news.esat.net...
Hi,

I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.
unsigned long myvarz = 3000000000

I am using MSVC++ 6.0

Any help please urgent....


The C language standard requires that type 'unsigned long'
can represent a minimum range of values from zero (0) through
4294967295, inclusive. Your value 3000000000 falls within
this range.
I compiled the following code with Microsoft
Visual C++ v6.0 :

#include <stdio.h>

int main()
{
unsigned long myvarz = 0;
myvarz = 3000000000;
printf("%lu\n", myvarz);
return 0;
}

I got output of:

3000000000
So perhaps you could specify what you mean by 'not taking'.
How did you verify there's a problem? With a debugger?
Did you print out the value? If so, which 'printf()' format
specifier did you use?
-Mike
Nov 15 '05 #4
"Joriveek" <no****@please.com> wrote in message
news:de**********@reader01.news.esat.net...
Hi,

I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.

I am using MSVC++ 6.0
I don't know what's not taking what, but long is at least 32-bit long, hence
unsigned long will fit your 3000000000 nicely.

But you'll have problems multiplying this number in integer arithmetics
(using longs only) by anything other than 1. If that's what you have, you
should probably use long long (or _int64 as per msvc++, which doesn't know
long long) or go for double or long double, which has more bits in mantissa
than simple long (up to 80 if I'm not mistaken are supported by x86/x87
FPU).
Any help please urgent....


Alive yet? :)
Alex
Nov 15 '05 #5
Joriveek wrote on 29/08/05 :
I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.

I am using MSVC++ 6.0


Check your ULONG_MAX (in <limits.h>) It could be not big enough for the
value you want.

In that case, you have several solutions:

Use a smaller value.
Use a larger type:
- [C99] long long or unsigned long long
- some extension of your IDE with '64' in its name...
Use a lower precision type (like a double).
Kill the dog.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"There are 10 types of people in the world today;
those that understand binary, and those that dont."
Nov 15 '05 #6

"Emmanuel Delahaye" <em***@YOURBRAnoos.fr> wrote in message
news:mn***********************@YOURBRAnoos.fr...
Joriveek wrote on 29/08/05 :
I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.

I am using MSVC++ 6.0


Check your ULONG_MAX (in <limits.h>) It could be not big enough for the
value you want.


It is large enough. I suspect OP didn't tell us the
whole story.

-Mike
Nov 15 '05 #7
ma*******@gmail.com wrote:
Joriveek wrote:
Hi,

I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.


#include <stdio.h>

int main(void)
{
unsigned int myvarz = 3000000000;
printf("%u\n",myvarz);
return 0;
}
This is working in msvc++ 6.0 and gcc.


It should 'work' on any implementation, but may print values
like 24064 since unsigned int is not required to have more than
16 value bits.

--
Peter

Nov 15 '05 #8
"Mike Wahler" <mk******@mkwahler.net> writes:
"Emmanuel Delahaye" <em***@YOURBRAnoos.fr> wrote in message
news:mn***********************@YOURBRAnoos.fr...
Joriveek wrote on 29/08/05 :
I want to store myvarz = 3000000000;

I have declared myvarz as unsigned long; still not taking.

I am using MSVC++ 6.0


Check your ULONG_MAX (in <limits.h>) It could be not big enough for the
value you want.


It is large enough. I suspect OP didn't tell us the
whole story.


He certainly didn't. The above is all the information the OP gave us,
except for the "Any help please urgent...." at the end of the article.
There's no reason to think he can't store the value 3000000000 in an
unsigned long, and no clue what he means by "still not taking".

If it's really urgent, presumably he'll be following this thread and
will jump in any moment with a clearer explanation of what he's asking
for. Until then, there's really no point in speculating.

I'm tempted to suggest that if somebody posts an unclear question, and
somebody else has posted a followup asking for clarification, we
should drop the thread. Unfortunately there doesn't seem to be any
good way to drop a thread.

To any newbies reading this:

If you're having a problem, please give us the information we need to
help you solve it. I understand that it's hard to know just what
information is needed, so sometimes we'll need to go back and forth a
couple of times. Some hints:

Provide a small complete (compilable and executable) program that
exhibits the problem. The "compilable and executable" part is
optional if the problem is that it won't compile or execute.

Don't use any system-specific headers. If you need them to
illustrate the problem, you need to post to a system-specific
newsgroup. If you don't know which headers are system-specific,
we'll be glad to offer advice. (We're sometimes a bit
over-sensitive about topicality, so be patient.)

Tell us what you expect the code to do and what it actually does.
If you get error messages, show them to us. Cut-and-paste both
the code and the error messages; don't try to summarize or re-type
them.

If your problem description is equivalent to "It doesn't work",
you're not giving us enough information.

These are not arbitrary rules; they're ways you can help us to help
you. Any extra time they cost you will be more than paid back in the
speed with which we can either give you an answer to tell you where to
find the people who can.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #9

"Peter Nilsson" <ai***@acay.com.au> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
ma*******@gmail.com wrote:
Joriveek wrote:
> Hi,
>
> I want to store myvarz = 3000000000;
>
> I have declared myvarz as unsigned long; still not taking.


#include <stdio.h>

int main(void)
{
unsigned int myvarz = 3000000000;
printf("%u\n",myvarz);
return 0;
}
This is working in msvc++ 6.0 and gcc.


It should 'work' on any implementation, but may print values
like 24064 since unsigned int is not required to have more than
16 value bits.


Note that the OP indicated he's using type 'unsigned long',
not 'unsigned int'. 'unsigned long' must contain at least
32 bits.

-Mike

Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For...
34
by: Andy | last post by:
Hi, Are 1 through 4 defined behaviors in C? unsigned short i; unsigned long li; /* 32-bit wide */ 1. i = 65535 + 3; 2. i = 1 - 3; 3. li = (unsigned long)0xFFFFFFFF + 3; 4. li = 1...
25
by: amit | last post by:
Hi, What will happen in following scenario.. long a = -2; longlong b = a long c; c = *(ulonglong *)&b; b = c; also when
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
9
by: luke | last post by:
Hi everybody, please, can someone explain me this behaviour. I have the following piece of code: long long ll; unsigned int i = 2; ll = -1 * i; printf("%lld\n", ll);
3
by: tutush | last post by:
Hi there, I have problem with importing my C++ code to C#. The c++ looks like these extern _declspec(dllexport) const char* SendAndReceiveBufferedWrp(__int64 hConnection, const char*...
14
by: moumita | last post by:
Hi All, I need to convert 4 bytes to an unsigned long. Suppose I have one array like unsigned char buf.I need to convert these 4 bytes into a single unsigned long. Is the following piece of code...
7
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
6
by: Kislay | last post by:
Consider the following code snippet unsigned int i=10; int j= - 2; // minus 2 if(i>j) cout<<"i is greater"; else cout<<"j is greater"; Since i is unsigned , j is greater . I know why , but...
13
by: Martin Wells | last post by:
I commonly use the likes of -1 for max unsigned values, or something like -7 to get 6 away from the max value; sort of like: unsigned x = ... if (-7 == x) puts("x is 6 away from its maximum");...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.