Quantcast

Jump to content

» «
Photo

Variable Issue

4 replies to this topic
toonskull
  • toonskull

    Necromancer

  • Members
  • Joined: 04 Aug 2009

#1

Posted 09 July 2013 - 08:49 PM


I understand variables such as float, integer, byte, etc...

0A9D: readfile 0@ size 2 to 1@ //Reads 2 bytes from file into 1@
0A9D: readfile 0@ size 4 to 1@ //Reads 4 bytes from file into 1@

What I don't understand is this;

So my question; After 1@ is read from file, is 1@ a float or an integer? How is this decided?

Thanks!

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#2

Posted 09 July 2013 - 09:10 PM

Depends on what you're reading. Although it won't read a human-readable integer/float properly. It reads binary data instead, which can be pretty much anything.

toonskull
  • toonskull

    Necromancer

  • Members
  • Joined: 04 Aug 2009

#3

Posted 10 July 2013 - 12:34 AM

For refference take a look at my script here.

You will notice I went with 4 bytes on all of these, however integers values of 5@, 6@, 7@ are not floats and should not require 4 bytes.

Does an integer variable in Cleo occupy 2 bytes or 4 bytes?

What are the factors that it depends upon?

Maybe I am making more out of this than I should, just trying to understand this opcode fully.

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci
  • Joined: 30 Jan 2011
  • Brazil

#4

Posted 10 July 2013 - 01:34 AM

As Silent already said, it will be anything you want it to be, since you'll be reading binary data.
If you wrote a 4 byte integer, you should read a 4 byte intenger, but note that you can write a 1 or 2 byte integer (if it can occupy that space), and read too (CLEO will pad the other bytes...)

An example:
The float 1.0 in binary is represented as [00111111 10000000 00000000 00000000]
The integer 1065353216 has the same binary representation.

So, if you read it into a var, it will be whatever it want to be\whatever it was written as.

QUOTE
Does an integer variable in Cleo occupy 2 bytes or 4 bytes?

4 bytes


toonskull
  • toonskull

    Necromancer

  • Members
  • Joined: 04 Aug 2009

#5

Posted 10 July 2013 - 07:24 AM

Ok so I guess I was making mountains out of mole hills.

Thanks, Guys!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users