which *int* ?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.

If you must have an unsigned integer of size 32 bits, how would you code it up?

u32int
4
6%
uint32_t
30
42%
u32int_t
0
No votes
uint32
12
17%
unsigned int (I don't care about portability)
8
11%
something else
17
24%
 
Total votes: 71

User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: which *int* ?

Post by Solar »

pcmattman wrote:Any decent compiler (MSVC's, and GCC, in the least) will throw a warning about the conversion from unsigned to signed.
By default, GCC doesn't. Not even with -Wall. You need -Wextra. And do you know how many programmers are still calling "gcc ... > /dev/null", as to "get rid of all those useless warnings"?
Every good solution is obvious once you've found it.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: which *int* ?

Post by pcmattman »

By default, GCC doesn't. Not even with -Wall. You need -Wextra.
I guess that shows how long it's been since I've compiled without a large number of warning flags (plus -Werror) on...
User avatar
spere
Posts: 6
Joined: Mon Sep 07, 2009 1:51 pm
Location: Where ever my CBR600rr takes me..
Contact:

Re: which *int* ?

Post by spere »

earlz wrote:
spere wrote:Being a C# developer, it would be
uint
or
System.UInt32
:P didn't expect that one, did you?

Then again in masm i would use
VarName dw
ugh.. I hate C# in that respect.. Uint32. Just look at it. What an ugly name. It's inconsistent with every other language, and itself(where core types are lower case, such as int, float, object, string) Microsoft should've thought a little harder about that...
Well i think it (System.UInt32) is quiet clear on first read. This is, the number of bits being used, whether it is signed or unsigned and what the developer plans to store in the variable. Then again this is the CLR implementation and in C# we could bypass it by using uint. In which case the C# compiler would convert it into the the CLR implementation, so that the compiled code (DLL) could be used with other CLR compliant languages.

Using uint in C# is pretty much like
Solar wrote: "int" might be 32 bit, but it does neither guarantee nor say so. "int" says "a whatever-sized integer value, I don't really care". Whereas int32_t says "a 32bit integer, and make it exactly 32 bits because it's important".
Then again, i use C# because duty calls. I prefer Masm/Nasm and communicating directly with the chip or processor :mrgreen:
Last edited by spere on Fri Sep 11, 2009 2:13 am, edited 1 time in total.
mov ah, 4ch
int 21h
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: which *int* ?

Post by Solar »

I think earlz was referring to the name System.Uint32 as opposed to uint32, uint_32, uint32_t, UINT32 or any other "sane" way to name the type. 8)
Every good solution is obvious once you've found it.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: which *int* ?

Post by Troy Martin »

Solar wrote:I think earlz was referring to the name System.Uint32 as opposed to uint32, uint_32, uint32_t, UINT32 or any other "sane" way to name the type. 8)
In other words, System.Uint32 is the "Microsoft way". :wink:
pcmattman wrote:I guess that shows how long it's been since I've compiled without a large number of warning flags (plus -Werror) on...
My CFLAGS is like 4 lines long. It has most of the warning flags in existance for GCC. This way TBOS is a stable little beast, and I can't find a way to break the current development version. I should probably also find out if NASM has any nice warning flags.
Solar wrote:And do you know how many programmers are still calling "gcc ... > /dev/null", as to "get rid of all those useless warnings"?
Oh god I think I'm going to *BLARRRGGHHH*
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: which *int* ?

Post by earlz »

Solar wrote:
pcmattman wrote:Any decent compiler (MSVC's, and GCC, in the least) will throw a warning about the conversion from unsigned to signed.
By default, GCC doesn't. Not even with -Wall. You need -Wextra. And do you know how many programmers are still calling "gcc ... > /dev/null", as to "get rid of all those useless warnings"?

I'm not pessimistic with any warnings brought forth by anything not included by -Wall. As such, I strive to avoid warnings, but I also don't specify -Wextra and -Werror and all those... cause when I'm making something really quick "just work" I don't want to worry about (signed) (unsigned) casting crap. I want it to work with maybe a few warnings, and then I go back and fix the warnings once my prototype is complete and I want to make the code more "safe"

Also,

Code: Select all

if(true);
gives a warning.. though it's not unsafe or anything. It just *does nothing*.
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: which *int* ?

Post by Firestryke31 »

earlz wrote: Also,

Code: Select all

if(true);
gives a warning.. though it's not unsafe or anything. It just *does nothing*.
Lol, does it go someting like this?
gcc wrote: some.c: In function 'foo':
some.c:##: warning: stupid programmer detected
Anyway, I just use int and unsigned int, and others when needed, but for loops I usually use size_t. I should probably go and start using the size-specific ones, but I want to get what I have working on my computer first, then I can focus on portability.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
User avatar
spere
Posts: 6
Joined: Mon Sep 07, 2009 1:51 pm
Location: Where ever my CBR600rr takes me..
Contact:

Re: which *int* ?

Post by spere »

Solar wrote:I think earlz was referring to the name System.Uint32 as opposed to uint32, uint_32, uint32_t, UINT32 or any other "sane" way to name the type. 8)
so i gather :D

Microsoft sees .Net as the future of all Windows based development and being an OS enthusiast, that another one in my "sane" list.
=P~ another dll format to rip apart
Troy Martin wrote:In other words, System.Uint32 is the "Microsoft way". :wink:
Nail on the head scenario =D> (and uint)
mov ah, 4ch
int 21h
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: which *int* ?

Post by pcmattman »

It has most of the warning flags in existance for GCC. This way TBOS is a stable little beast
Sorry to jump OT, but I have to point out that you can have all the warnings in the world fixed, but still have an operating system that doesn't actually work (say, #PF's or triple faults all the time). Not having any warnings != having stable code. If you want to get closer to stable code you can run static code analysis. Truly stable code comes from hours of testing, debugging, and modifications, not from fixing warning messages.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: which *int* ?

Post by Troy Martin »

pcmattman wrote:
It has most of the warning flags in existance for GCC. This way TBOS is a stable little beast
Sorry to jump OT, but I have to point out that you can have all the warnings in the world fixed, but still have an operating system that doesn't actually work (say, #PF's or triple faults all the time). Not having any warnings != having stable code. If you want to get closer to stable code you can run static code analysis. Truly stable code comes from hours of testing, debugging, and modifications, not from fixing warning messages.
Sorry for bringing the OT further, but I think I should rephrase it. Before I added all sorts of warning flags, it was really unstable and even, in some parts, completely broken. After I added the warning flags, saw how horrible I am at coding (haha, just kidding), and fixed the multiple hundred warnings that GCC spat out at me, it ran with a perfect smoothness, completely working. So yeah, actually, adding the warning flags and fixing the warnings did make my OS stable. Even solved a couple #UDs and a GPF or two.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: which *int* ?

Post by earlz »

Troy Martin wrote: saw how horrible I am at coding (haha, just kidding)
so what your great at coding? Someones a bit stuck on themselves lol.

And my problem with System.Uint32 is even when you include the System namespace, you still have an ugly inconsistent piece of crap. Uint32. Could they not have at least followed there own unspoken standard and called it just `uint32` as all the other core types are? And wtf is a core type even doing in a namespace anyway?

Code: Select all

//this is microsofts next language namespace usage
Builtins.Compiler.System.Core.Type.Integers.Uint32
User avatar
spere
Posts: 6
Joined: Mon Sep 07, 2009 1:51 pm
Location: Where ever my CBR600rr takes me..
Contact:

Re: which *int* ?

Post by spere »

earlz wrote: And my problem with System.Uint32 is even when you include the System namespace, you still have an ugly inconsistent piece of crap. Uint32. Could they not have at least followed there own unspoken standard and called it just `uint32` as all the other core types are?
Who better then Microsoft to make this change :mrgreen: for better or for #-o
mov ah, 4ch
int 21h
fronty
Member
Member
Posts: 188
Joined: Mon Jan 14, 2008 5:53 am
Location: Helsinki

Re: which *int* ?

Post by fronty »

When programming with C# you don't have to use System.Uint32 or Uint32 if you prefer uint. Int32 ^ int, Uint32 ^ uint, Int64 ^ long, and so on. And don't say that it's bad that those shorter names don't tell the actual width of variable, because when you program C#, you always know that your int is 32 bits wide. C# standard says that int represents 32-bit integral value. There are no other possibilities.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: which *int* ?

Post by earlz »

fronty wrote:When programming with C# you don't have to use System.Uint32 or Uint32 if you prefer uint. Int32 ^ int, Uint32 ^ uint, Int64 ^ long, and so on. And don't say that it's bad that those shorter names don't tell the actual width of variable, because when you program C#, you always know that your int is 32 bits wide. C# standard says that int represents 32-bit integral value. There are no other possibilities.

I've always hated microsofts decision to make 64bit programming *look* like 32bit programming.. it just ends up in 3 or 4 years, when 64bit arithmetic is slightly faster than 32bit arithmetic, Windows will be *even* slower than other OSs
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: which *int* ?

Post by NickJohnson »

earlz wrote:
fronty wrote:When programming with C# you don't have to use System.Uint32 or Uint32 if you prefer uint. Int32 ^ int, Uint32 ^ uint, Int64 ^ long, and so on. And don't say that it's bad that those shorter names don't tell the actual width of variable, because when you program C#, you always know that your int is 32 bits wide. C# standard says that int represents 32-bit integral value. There are no other possibilities.
I've always hated microsofts decision to make 64bit programming *look* like 32bit programming.. it just ends up in 3 or 4 years, when 64bit arithmetic is slightly faster than 32bit arithmetic, Windows will be *even* slower than other OSs
Except that then they could just have the types actually be 64 bit, and things would act exactly the same, except for the memory usage. Of course, the entire system would have to be recompiled to update the library interfaces...
Post Reply