473,804 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is 0xFFFFFFF ?

in a program it is passing like that:

#define INFINITY 0xFFFFFFF

it is a ASCII code of what? or is it a address that a pointer hold?
so adress of what?

Jan 24 '07
30 39477
Chris Dollin wrote:
Harald van Dijk wrote:
iskeletor wrote:
in a program it is passing like that:

#define INFINITY 0xFFFFFFF

it is a ASCII code of what? or is it a address that a pointer hold?
so adress of what?
0xFFFFFFFF is a hexadecimal integer constant.

Nitpick: the OP's text said 0xFFFFFFF, not 0xFFFFFFFF.
(One difference is that on a 32-bit-int implementation,
the OP's text will become a signed int literal but
yours will become an /unsigned/ int literal. If I
remember correctly.)
Oops, quite right. In C99, 0xFFFFFFFF would be a signed long long (on a
32-bit-int 32-bit-long implementation) , by the way.

Jan 24 '07 #11
Matthew Hicks wrote:
>
Please don't top-post. Thanks. Fixed.
>>iskeletor wrote:

in a program it is passing like that:

#define INFINITY 0xFFFFFFF

it is a ASCII code of what? or is it a address that a pointer
hold? so adress of what?

It's a biggish [1] number, that's all.

[1] From the point of view of 32-bit machine integers in twos
complement.
From any reasonable point of view, it's a peanut: not even 2pow32,
let alone (searches for a number) 10pow100.
Or it's a small negative number, -1. It's only a big positive number
(what it is supposed to represent given the context) if the
system/program uses 32-bit unsigned ints.
Count Fs.

It's positive anyway: if the value /was/ 0xFFFFFFFF, then on a 32-bit
implementation it will be an unsigned int, not a signed int. IIRC.
Only in logical test, you would have to be carefull if you used it in an
assignment operation.
---Matthew Hicks
Jan 24 '07 #12
"Matthew Hicks" <md******@uiuc. eduwrote in message
news:b6******** *************** **@news.ks.uiuc .edu...
Ignore my previous post as Mr. Tobin pointed out that there are only 7 hex
characters. On a side note, 0x7fffffff would probably be a better general
coice for infinity on most 32-bit machines.
Yes and no.

First, there are some constants in some system include file somewhere (never
figured out which one, or cared) which give the min and max values for the
types. This is the "right" way to define "infinity" in the sense you
intend.

However, ...

Those of us who have been around the block several times have figured out
that just about every machine in the world that we care about uses 2's
complement representation, and that the generalities defined in the Posix or
Single-Unix standard don't really apply in the world. Those of us who are
"in the know" might use something like this for the limits.

#define UINFINITY ((unsigned)-1)
#define SMIN ((int)(UINFINIT Y ^ (UINFINITY >1))
#define SMAX ((int)(UINFINIT Y >1))
/* The constants above should be proof to the over-generalizing lunatics
who write
** standards that you don't need to overcomplicate things. Note that the
** expressions above--assuming I didn't botch them--will work with any
** size of 2's complement integer.
*/

I don't claim that the expressions above are correct (I'm doing them
on-the-fly), but I'm sure you get the idea.

--
David T. Ashley (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
Jan 24 '07 #13
David T. Ashley wrote, On 24/01/07 16:07:
"Matthew Hicks" <md******@uiuc. eduwrote in message
news:b6******** *************** **@news.ks.uiuc .edu...
>Ignore my previous post as Mr. Tobin pointed out that there are only 7 hex
characters. On a side note, 0x7fffffff would probably be a better general
coice for infinity on most 32-bit machines.

Yes and no.

First, there are some constants in some system include file somewhere (never
figured out which one, or cared) which give the min and max values for the
types. This is the "right" way to define "infinity" in the sense you
intend.

However, ...

Those of us who have been around the block several times have figured out
that just about every machine in the world that we care about uses 2's
complement representation, and that the generalities defined in the Posix or
Single-Unix standard don't really apply in the world. Those of us who are
"in the know" might use something like this for the limits.

#define UINFINITY ((unsigned)-1)
#define SMIN ((int)(UINFINIT Y ^ (UINFINITY >1))
#define SMAX ((int)(UINFINIT Y >1))
/* The constants above should be proof to the over-generalizing lunatics
who write
** standards that you don't need to overcomplicate things. Note that the
** expressions above--assuming I didn't botch them--will work with any
** size of 2's complement integer.
*/
#include <limits.h>

Wasn't that less work?
I don't claim that the expressions above are correct (I'm doing them
on-the-fly), but I'm sure you get the idea.
Those of us who have been around the block a good few times and actually
know the language know the header where it is defined and so don't have
to do them "on-the-fly" or dig them out of some custom header we have
written, or even worry about what representation is used. We just
include limits.h which is guaranteed to exist and use the defines there
in. Far less work and far more reliable.

Since you know they are in a header already I really can't see why you
would bother to write them yourself.
--
Flash Gordon
Jan 24 '07 #14
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:5k******** ****@news.flash-gordon.me.uk...
David T. Ashley wrote, On 24/01/07 16:07:
>>
Those of us who have been around the block several times have figured out
that just about every machine in the world that we care about uses 2's
complement representation, and that the generalities defined in the Posix
or Single-Unix standard don't really apply in the world. Those of us who
are "in the know" might use something like this for the limits.

#define UINFINITY ((unsigned)-1)
#define SMIN ((int)(UINFINIT Y ^ (UINFINITY >1))
#define SMAX ((int)(UINFINIT Y >1))
/* The constants above should be proof to the over-generalizing
lunatics who write
** standards that you don't need to overcomplicate things. Note that
the
** expressions above--assuming I didn't botch them--will work with any
** size of 2's complement integer.
*/

#include <limits.h>

Wasn't that less work?
>I don't claim that the expressions above are correct (I'm doing them
on-the-fly), but I'm sure you get the idea.

Those of us who have been around the block a good few times and actually
know the language know the header where it is defined and so don't have to
do them "on-the-fly" or dig them out of some custom header we have
written, or even worry about what representation is used. We just include
limits.h which is guaranteed to exist and use the defines there in. Far
less work and far more reliable.

Since you know they are in a header already I really can't see why you
would bother to write them yourself.
I agree with you, actually.

The preprocessor constants of the style I mentioned were first spotted by me
in the GMP (not the verbatim same thing, but the style). I noticed at that
time that they were fairly clever, in that they worked for any size of
integer.
Those of us who have been around the block a good few times and actually
know the language know the header where it is defined and so don't have to
do them "on-the-fly" or dig them out of some custom header we have
written, or even worry about what representation is used. We just include
limits.h which is guaranteed to exist and use the defines there in. Far
less work and far more reliable.
I've never actually seen a machine with an integer representation other than
2's complement. I'm not sure I could write portable code for such a
machine. I'm not sure I'd want to. With integers, knowledge of the
representation is baked into the way I think.

For example:

<BEGIN>
unsigned msb, lsb, thing_to_add;

lsb += thing_to_add;

if (lsb < thing_to_add)
msb++;
<END>

The code above works because it makes assumptions about how the integer is
represented and what will happen if you add too much to it. I don't really
want to program on machines where those fundamental assumptions about 2's
complement integer arithmetic don't hold.

--
David T. Ashley (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
Jan 24 '07 #15
David T. Ashley wrote, On 24/01/07 18:54:

<snip>
I've never actually seen a machine with an integer representation other than
2's complement. I'm not sure I could write portable code for such a
machine. I'm not sure I'd want to. With integers, knowledge of the
representation is baked into the way I think.
A lot of the time it makes no difference. Also, sometimes it is worth
making non-portable assumptions.
For example:

<BEGIN>
unsigned msb, lsb, thing_to_add;

lsb += thing_to_add;

if (lsb < thing_to_add)
msb++;
<END>

The code above works because it makes assumptions about how the integer is
represented and what will happen if you add too much to it.
Actually it does *not* depend on the representation for at least two
reasons.
1) As you have declared the variables as unsigned it makes no difference
which representation is used for signed arithmetic.
2) The C standard defined arithmetic on unsigned integers as wrapping in
the way you seem to expect. By the way, it defines the wrapping as not
being an overflow, a subtle point but important when reading the standard.
I don't really
want to program on machines where those fundamental assumptions about 2's
complement integer arithmetic don't hold.
I've written code that depended on signed integers wrapping on overflow.
In the situation it was not unreasonable, but with hindsight I could
have done it using unsigned int instead and sidestepped the problem.
Some algorithms would have required a little tweaking, but nothing
difficult. I can't think of anything I have written since I left
assembler behind that depended on 2s complement though, apart from
reading numbers from an interface where the interface defined they were
2s complement.
--
Flash Gordon
Jan 24 '07 #16
"David T. Ashley" <dt*@e3ft.comwr ites:
"Matthew Hicks" <md******@uiuc. eduwrote in message
news:b6******** *************** **@news.ks.uiuc .edu...
Ignore my previous post as Mr. Tobin pointed out that there are only 7 hex
characters. On a side note, 0x7fffffff would probably be a better general
coice for infinity on most 32-bit machines.

Yes and no.

First, there are some constants in some system include file somewhere (never
figured out which one, or cared) which give the min and max values for the
types. This is the "right" way to define "infinity" in the sense you
intend.
The header is <limits.h>. If you care about the minimum and maximum
values for the predefined integer types, you really should know this.
However, ...

Those of us who have been around the block several times have figured out
that just about every machine in the world that we care about uses 2's
complement representation, and that the generalities defined in the Posix or
Single-Unix standard don't really apply in the world. Those of us who are
"in the know" might use something like this for the limits.

#define UINFINITY ((unsigned)-1)
#define SMIN ((int)(UINFINIT Y ^ (UINFINITY >1))
#define SMAX ((int)(UINFINIT Y >1))
/* The constants above should be proof to the over-generalizing lunatics
who write
** standards that you don't need to overcomplicate things. Note that the
** expressions above--assuming I didn't botch them--will work with any
** size of 2's complement integer.
*/

I don't claim that the expressions above are correct (I'm doing them
on-the-fly), but I'm sure you get the idea.
You need another ')' at the end of the definition of SMIN.

But I fail to see how this proves that "you don't need to
overcomplicate things". It's *much* simpler to add a

#include <limits.h>

to the top of your source file and use INT_MIN, INT_MAX, and UINT_MAX.
I don't care, or need to care, what tricks are used to define them; I
know that they'l give me the correct values. And I don't have to care
whether the system uses two's complement or not.

Sure, if <limits.hdidn 't exist, I might write something like the
above and live with the fact that it only works for two's complement
(assuming that's true; I haven't analyzed your definitions). But
<limits.hdoes exist, and it's silly not to use it.

--
Keith Thompson (The_Other_Keit h) 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.
Jan 24 '07 #17
"Lew Pitcher" <lp******@sympa tico.cawrites:
[...]
0xFFFFFFF is taken as an integer value

It /might/ be used as the initializer for a pointer
It /might/ be used as the initializer for an integer data item

It depends on the context
0xFFFFFFF cannot be used as the initializer for a pointer unless it's
explicitly converted. There is no implicit integer-to-pointer
conversion except for the special case of null pointer constants.

--
Keith Thompson (The_Other_Keit h) 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.
Jan 24 '07 #18
David T. Ashley wrote:
I've never actually seen a machine with an integer representation other than
2's complement. I'm not sure I could write portable code for such a
machine. I'm not sure I'd want to. With integers, knowledge of the
representation is baked into the way I think.

For example:

<BEGIN>
unsigned msb, lsb, thing_to_add;

lsb += thing_to_add;

if (lsb < thing_to_add)
msb++;
<END>

The code above works because it makes assumptions about how the integer is
represented and what will happen if you add too much to it.
No, it doesn't make any such assumptions. The above code will work on
*any* conforming C implementation (because you are using unsigned
types). When you work with unsigned integers, the representation of
signed integers (and what happens when they overflow) is irrelevant.
I don't really
want to program on machines where those fundamental assumptions about 2's
complement integer arithmetic don't hold.

--
Clark S. Cox III
cl*******@gmail .com
Jan 24 '07 #19
"Keith Thompson" <ks***@mib.orgw rote in message
news:ln******** ****@nuthaus.mi b.org...
"David T. Ashley" <dt*@e3ft.comwr ites:

But I fail to see how this proves that "you don't need to
overcomplicate things". It's *much* simpler to add a

#include <limits.h>

to the top of your source file and use INT_MIN, INT_MAX, and UINT_MAX.
I don't care, or need to care, what tricks are used to define them; I
know that they'l give me the correct values. And I don't have to care
whether the system uses two's complement or not.

Sure, if <limits.hdidn 't exist, I might write something like the
above and live with the fact that it only works for two's complement
(assuming that's true; I haven't analyzed your definitions). But
<limits.hdoes exist, and it's silly not to use it.
My arguments about complication come from some of the prohibitions on "magic
numbers". I've been blasted all the time for code like:

if (x 87192) /* Number of hairs a cat might have. */
{

My counter-argument is that the only time it makes sense to define something
as a preprocessor constant is if:

a)There is some special symbolic clarity (bits in a hardware control
register, for example), OR

b)The constant appears in more than one place, AND

c)The occurrences are linked in a way where if one changes, the others must
change, too.

If those conditions aren't met, it just doesn't matter. I'm neither for or
against it.

Mentally (and maybe I was having a low-caffeine moment), I saw a bit of that
in this discussion.

Integer size and max values of integers and so on are part of the "ether"
(i.e. the environment). Why define a special constant for the maximum when
you can use something like ((unsigned) -1)? What special benefit is there?

Some of the code I've seen in my time has made a lot of work for me. For
example, I've seen stuff like:

if (x UINT8_TWO)
{

If I'm going after a nebulous bug, it means that every time I see something
like that I have to verify the symbol the preprocessor is using. It is
unnecessary work.

It is simpler to say:

if (x 2)
{

On a two's-complement machine, some of the stuff in <limits.hseem s ... on
the border of being unnecessary. It is right on the border of my threshold
for being unnecessary.
--
David T. Ashley (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
Jan 24 '07 #20

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

Similar topics

2
3112
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is burns. Here is the code: $frank = "burns";
220
19190
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
699
34279
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
92
6550
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption? cheers, reed
137
7206
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain 3) when it comes true. - 5) I have developed for many years (>18) in many different environments,...
12
11191
by: Dario | last post by:
The following simple program behaves differently in Windows and Linux . #include <stdexcept> #include <iostream> #include <string> using namespace std; class LogicError : public logic_error { public: string desc;
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10337
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.