
-----------------------------------
TokenHerbz
Fri Oct 07, 2005 11:42 am

Real vs. Int
-----------------------------------
yeah i have a question about reals and int...

I personally use int because it works with drawfills, and reals dont, but reals look better, especially when trying to get a ball to gradually go faster...

Im aware that you can *round* the real to use it as n int, but wont it round it to the whole?  making it usless as a decimal??

I just need some info on how this works...

-----------------------------------
Tony
Fri Oct 07, 2005 12:13 pm

Re: Real vs. Int
-----------------------------------

Well you can't exactly fill 0.25 of a pixel, now can you? :think:

-----------------------------------
codemage
Fri Oct 07, 2005 12:15 pm


-----------------------------------
Some functions/procs don't work with reals.  You have to live with that.

You can store variables as reals in some cases, and then round them before you actually use them in their respective function.  ie:

functionthattakesanint ( round ( realnumbervariable) )

-----------------------------------
TokenHerbz
Fri Oct 07, 2005 2:42 pm


-----------------------------------
ok well to fill the oval on a real variable...

shall i make a for statment??

for i: 1 .. 10
     drawoval(x,y,size+i,size+i,7)    %%Where z,y,and size are reals
end for

Will that work?? etc::  i dont want to test it atm, i gotta go to work

-----------------------------------
md
Fri Oct 07, 2005 2:48 pm

Re: Real vs. Int
-----------------------------------

Well you can't exactly fill 0.25 of a pixel, now can you? :think:

I disagree; if you fill a quarter of a blue (RGB[0,0,255]) with red then the pixel would become blue + red/4 = RGB[255/4,0,255]. This goes a surprisingly long way to reducing jaggies when you are rendering polygons.

-----------------------------------
Cervantes
Fri Oct 07, 2005 2:53 pm


-----------------------------------
Tokenherbz: No, that will not work.  Did you even read codemage's post?  Round it!

-----------------------------------
[Gandalf]
Fri Oct 07, 2005 2:53 pm


-----------------------------------
No, they need to be ints...

The advantage of using real numbers in this case is that you can use decimal numbers for calculations, which makes a rounded number more accurate, ie:
var numA, numB, numC : real
var intA, intB, intC : int %The rounded ints
intA := 3
numA := 3.3
intB := 4
numB := 4.1
intC := 3
numC := 3.4
put numA, " + ", numB, " + ", numC
put "real answer: ", numA + numB + numC %if possible, use real numbers
put "rounded: ", round (numA + numB + numC) %this is the better if ints are needed
put intA, " + ", intB, " + ", intC
put "rounded ints: ", intA + intB + intC %if you used ints for calculations

-----------------------------------
Tony
Fri Oct 07, 2005 3:10 pm

Re: Real vs. Int
-----------------------------------
if you fill a quarter of a blue (RGB
You're absolutly right. Though that's not how Turing's draw functions work :wink:
