Click here to Skip to main content
15,923,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: convert from size_t to unsigned int Pin
George_George27-Jul-07 23:54
George_George27-Jul-07 23:54 
AnswerRe: convert from size_t to unsigned int Pin
John R. Shaw28-Jul-07 0:05
John R. Shaw28-Jul-07 0:05 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 0:12
George_George28-Jul-07 0:12 
GeneralRe: convert from size_t to unsigned int Pin
John R. Shaw28-Jul-07 0:37
John R. Shaw28-Jul-07 0:37 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 1:25
George_George28-Jul-07 1:25 
GeneralRe: convert from size_t to unsigned int Pin
Eytukan28-Jul-07 3:27
Eytukan28-Jul-07 3:27 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 3:36
George_George28-Jul-07 3:36 
GeneralRe: convert from size_t to unsigned int Pin
Eytukan28-Jul-07 4:05
Eytukan28-Jul-07 4:05 
George_George wrote:
Do you think convert from size_t to unsigned int will cause data lost on 32-bit platform?


You will loose if you send signed number. Ok, test it by yourself :
<br />
	int nIntNeg = -100;<br />
	int nIntPos = 100;<br />
	size_t sz;<br />
	sz=nIntPos;<br />
	cout<<"\n"<<sz;<br />
<br />
	sz=nIntNeg;<br />
	cout<<"\n"<<sz<<endl;<br />

The point here is not about you will/will-not loose data, but it's to say that you wont get into a situation where a function would return signed number for a size_t type.
Eg:

<br />
	std::string st;<br />
	st="";<br />
	cout<<st.size();<br />


At the worst, st's size can me only 0, can't go below that. So you get the point? size_t s are meant for unsigned data. If you send signed numbers, you WILL loose it.






He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.

-Marc Clifton.

Best wishes to Rexx[^

GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 19:28
George_George28-Jul-07 19:28 
AnswerRe: convert from size_t to unsigned int Pin
Roger Broomfield28-Jul-07 3:03
Roger Broomfield28-Jul-07 3:03 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 3:27
George_George28-Jul-07 3:27 
GeneralRe: convert from size_t to unsigned int Pin
Eytukan28-Jul-07 3:33
Eytukan28-Jul-07 3:33 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 3:38
George_George28-Jul-07 3:38 
GeneralRe: convert from size_t to unsigned int Pin
Eytukan28-Jul-07 4:14
Eytukan28-Jul-07 4:14 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 19:30
George_George28-Jul-07 19:30 
AnswerRe: convert from size_t to unsigned int Pin
bob1697228-Jul-07 5:18
bob1697228-Jul-07 5:18 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 19:33
George_George28-Jul-07 19:33 
GeneralRe: convert from size_t to unsigned int Pin
bob1697228-Jul-07 20:43
bob1697228-Jul-07 20:43 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 21:55
George_George28-Jul-07 21:55 
GeneralRe: convert from size_t to unsigned int Pin
bob1697229-Jul-07 18:13
bob1697229-Jul-07 18:13 
GeneralRe: convert from size_t to unsigned int Pin
George_George29-Jul-07 18:25
George_George29-Jul-07 18:25 
AnswerRe: convert from size_t to unsigned int Pin
Mark Salsbery28-Jul-07 6:44
Mark Salsbery28-Jul-07 6:44 
GeneralRe: convert from size_t to unsigned int Pin
George_George28-Jul-07 19:34
George_George28-Jul-07 19:34 
GeneralRe: convert from size_t to unsigned int Pin
Mark Salsbery30-Jul-07 4:53
Mark Salsbery30-Jul-07 4:53 
GeneralRe: convert from size_t to unsigned int Pin
George_George30-Jul-07 18:54
George_George30-Jul-07 18:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.