Integer to Real? Real to Integer?

xPass

All aboard the xPass Express!
Reaction score
26
I have browsed through certain threads and tutorials, but I have yet to find an answer to this:

1) Why do people use integer or real instead of vice-versa?

2) Which one is better and more efficient?

3) In what way are they?

4) What's the point of converting integer to real in skills?

5) What is String to Real?
 

DioD

New Member
Reaction score
57
1) why people drink coffe or tea instead of vice-versa?
2) Which one is better and more efficient?

...

open wikipedia and read what is integer and what is real.
 

Jedi

New Member
Reaction score
63
1-With some functions, you need to use reals, some of them you need to use integers.

2-Using integers easier if you don't need reals.

3-Integers are normal numbers:
1,2,3,4,5,6,7,0,-100,25063,-99999.

Reals are numbers with decilmal:
1.50, 3.45, 7.4301, -5.000, 9.500, 0.000

4-For example ,if you are going to use Unit - Damage action.You need to use a real number.Because a damage is real number.Lightning and unit colors real.

Trigger:
  • Player - Set Player 1 (Red) Current gold to 750

You can't add a player 750.35 gold.Gold is an integer number and it can't have decilmals.

5-It converts string to real =)Like a player chats -camera 1000, you convert 1000 to number and set players camera height.
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Integer is a whole number. Real can have decimals.

Which one is better, depends on what you want to use. If you want to use a number with decimal, you'd use real. Otherwise you'd use integer. If you see reals such as 1.00 or 2.00 used, it means the function itself requires real value. Such as distance, you can't enter an integer.

String to real basically converts a string, to a real number. For example the string is taken from entered chat string, the player types 5.50. If this string is converted to real, it becomes a real value of 5.50. (But personally I use integers for such conversion as real is not necessary, unless I want the player to enter the duration or distance.)

It's really just a preference, using integer or real instead won't really matter unless the function requires either one.

P.S. You REALLY should start searching for what you need, whether it is on this forum or not. JASS is just another scripting syntax, means there are other scripting syntax that are not in the world editor, which means you can find it on the net, such coding(just a little different).

jedi said:
3-Integers are normal numbers:
1,2,3,4,5,6,7,0,-100,25063,-99999.

Reals are numbers with decilmal:
1.50, 3.45, 7.4301, -5.000, 9.500, 0.000
Integers are whole numbers. 5.5 is also a normal number...

jedi said:
6-I can't believe you ask this questions :O

Everybody has to learn it some time, and why did you just double post o.o
 

xPass

All aboard the xPass Express!
Reaction score
26
Well, sorry for being a newb!! :D Thanks for teaching too...
 

staind25

TH.net Regular
Reaction score
7
They're fair questions. I think generally though, here's something else you should know:

For the world editor, you HAVE to use reals for some things, integers for others. This is just how the functions are set up for you.

In "real" programming, you generally have the choice between using real or integer. You could use an integer for doing something as simple as counting the days in a month, or a little more complex as doing arithmetic on an array index. You'd probably be better off using reals with stuff like money.

Hope that helps solidify the concept a bit :)

Edit: Just some additional info...another reason to keep reals and integers separate from each other is that you can't mix them when doing operations on them. For example, if you try to multiply a real and an integer together, certain programming languages will give you a compile error. 2 * 2.0, for example, is incorrect (However, some compilers are smart enough to know what you mean). 2.0 * 2.0 is correct, and so is 2 * 2. Alternatively, you can convert between reals and integers, which you addressed in your post. You might decide to convert one to another so that you could do arithmetic on them.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top