why is this a minus?

For general discussion related FlowStone
VPDannyMan
Posts: 118
Joined: Mon Jan 04, 2010 4:50 am

Re: why is this a minus?

Post by VPDannyMan »

billv wrote:
VPDannyMan wrote:What is the largest number an integer in FS can hold?

A standard 32-bit integer can handle -2,147,483,648 through 2,147,483,647.
I knew it was guru math trick :lol: :lol: thanks for the reminder
thanks VPDannyMan :)
can you tell me why this happens....?? still :?


No worries, I was not sure if that was the cause or not, but in other languages I would have instantly thought about resolution so I mentioned it..
Trog has a pretty good detailed explanation for you above this post..
billv
Posts: 1165
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia
Contact:

Re: why is this a minus?

Post by billv »

Yeh, I get this part.. :)
trogluddite wrote:error - trying to "fit a quart into a pint pot."

But still struggling with the rest of it...
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: why is this a minus?

Post by Nubeat7 »

so if ruby converts "normal" int to "long" ints automaticly if there is a overflow, the result is right inside ruby and when you output it via a string because a string dont care about length - its just a row of characters - but if you use the result further and get lower numbers again (if you need to divide it by 100....) it should work right doing all the math inside ruby and output the right number as int to FS as long it is small enough for FS (32 bit int)
Jay
Posts: 276
Joined: Tue Jul 13, 2010 5:42 pm

Re: why is this a minus?

Post by Jay »

Oh Trogg i never noticed your post, i think i was half cut at the time sorry ha ha!

Thanks for that explanation! everywhere i looked on the net for info after VPDannyMans post, told me the max length of 32bit ints but not much else about the hows and whys of it all so cheers for that! also i never knew what the little e's were in numbers in SM until now! i will read your post a few times to pick it all up

good posts from everyone else as well thanks!

Best Regards
VPDannyMan
Posts: 118
Joined: Mon Jan 04, 2010 4:50 am

Re: why is this a minus?

Post by VPDannyMan »

These are the primary data types that are available to Malc to add and use in FS.

Boolean, 1 byte, True or False (Available in FS)

Short Integer. 2 bytes signed: -32768 to 32767 unsigned: 0 to 65535

Integer. 4 bytes signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 (Available in FS)

Long integer. 4 bytes signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295

Floating point number. 4 bytes +/- 3.4e +/- 38 (~7 digits) (Available in FS)

Double precision floating point number. 8 bytes +/- 1.7e +/- 308 (~15 digits) (Available in FS)

Long double precision floating point number. 8 bytes +/- 1.7e +/- 308 (~15 digits)

Here is what the above means..
Data Type, followed by Length, followed by Resolution, followed by the Difference in resolution if Unsigned.
The Length part tells you how many bytes of memory it takes to store the value.
Resolution is how large/small the value can be that is stored.
Difference in Resolution if Unsigned is what numbers it can store up to if there is no sign.

As far as I know, Ruby should have the identical set.
Also note I could be wrong on what I identified as (Available in FS). Maybe someone can double check that if they have time..

Hope that helps
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: why is this a minus?

Post by trogluddite »

Yup, that's about right, VP - though we could break it down a little bit further....

Green...
Boolean - see 'integer'...
Integer - 4 byte signed (NB - 'green' booleans are really integers that only have zero and one values)
Float Single - 4 byte
(plus Strings etc...)

Stream...
Boolean - bitmasks containing either 32 'Off' bits, or 32 'On' bits.
Integer - 4 byte
Float Single - 4 byte
Float Double - 8 byte (Limited to just a few primitives - NOT available in code or assembly)

Ruby...
Boolean - the special Ruby values "false" and "true"
FixNum - same as a 4 byte Integer
BigNum - an integer of ay length (Ruby auto-coverts between BigNum and FixNum as requred)
Float - always double precision.
Rational - numbers held as fractions (e.g. 1/3, 345/678) always with the lowest possible denominator.
Complex - complex numbers. e.g. (x + yi) - the 'x' and 'y' could be any of the above number types.

When sending a Ruby number to a 'green' connected, values will be truncated (Integers) or rounded (floats), to 32bit (4byte) versions - 'Rationals' are, I think, turned into Floats, and 'Complex' don't have any 'green' equivalent.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
tiffy
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: why is this a minus?

Post by tiffy »

Wow, I like that kind of Math!
:mrgreen:
Post Reply