What is an integer?

What is an integer?

I’m curious what it is, but I just can’t get my head wrapped around it!

An integer is a number that can be written without a fractional component. For example, 21, 4, 30 and -2048 are integers, while 9.75, 5(1/2) and sqrt(2) are not integers. If you intended integers in maths then these are integers; if in computer science Wikipedia can help you with that.

4 Likes

April fools!

But srsly tho, thanks!

I hope someone actually does find it useful…

2 Likes

The informal topic made me to think of this, sigh

3 Likes

E-xactly

Nice. I should have thought of this…

1 Like

One addition to Ergastolator1’s post (at least as far as Java is concerned)

an int is a number
an Integer is a pointer that can reference an object that contains a number

3 Likes

What do you mean by pointer, exactly?

An integer is a number that doesn’t have any decimals, basically.

Probably more complex (thx wikipedia, for turning everything into a 1000+ word essay) than that, but yeah.

All objects in Java are references and you can use them like pointers ( references )

A reference is an index into a memory management table. Typically the memory management table is protected from direct access. In Java’s case the reference can’t be manipulated manually, as any read of the variable will result in returning the referenced object.

This has a lot of implications, but is necessary for decent automatic garbage collection. Garbage collection sometimes involves moving objects in memory to create larger areas of free space (for needed objects that cannot fit into the current memory holes). If Java exposed a pointer, then after memory compaction, you might have the “old” address of the memory.

By using references, your reference is guaranteed to stay the same, even if the actual location of memory moves around. Internal to the JVM is a reference to pointer table, but you will never get to see it from a running program; because, if you ever touched it, it would mess up the automatic memory management.

A Java both int and Integer are used to store integer type data the major difference between both is type of int is primitive while Integer is of class type. … int helps in storing integer value into memory. Integer helps in converting int into object and to convert an object into int as per requirement

3 Likes

Ah, ok.

IK what a reference is, but I haven’t really used Java (I use Go, which uses GC too).

CS:GO?

No, Go (Golang).

i know.

I once wrote this on a forum:

We are all in some way always beginners :slight_smile:

because what you learn today after 5 years is outdated
and to be a programmer you must constantly learn

People think I love computers
no ! computers are just tools for me to express myself

when I learned Java
80% I immediately forgot, in the remaining 20%…18% is deprecated
and that 2% are something I know

people often ask me
how much do I know about Java (or actually anything related to IT all the way to html )
I say 2% :slight_smile:

many think I’m joking!
or how this is a sign of my modesty :blush:

but no… !

they do not understand how huge it is!

So if someone tells you he knows 100% or 50% or 20% or 5%
they lie to you !!!

many think to be a programmer is something like a matrix movie
but you actually sit and drink 5+ coffee or energy drinks
watching in the debugger all day (most at night)

it’s so abstract…
it’s a job that someone can work for a maximum of 5 years
and after that you become crazy (just waiting to see the green grass and the sun)

one of the worst things is…
whenever someone asks me (friend or a girl) what I did today ?
I just answer - nothing ! :confused:

because if I start answering them
after 30 sec they are lost (they do not understand what I’m talking about)

Larry Wall (author of Perl) describes three good qualities in a good programmer:
laziness, impatience and hubris. Laziness may sound like a bad trait for any employee to have, but IT managers have said that if you want to find the best way to do something, ask a lazy person. Chances are, that person will have found the quickest and most effective way to do it.

wtfm

4 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.