If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Basic maths not so basic
13 posts
• Page 1 of 2 • 1, 2
Basic maths not so basic
This makes no sense as the answer should be 1 , any whole number divisible by itself is 1 even 0, 0/0=1 or 1x0=0 ?
- Attachments
-
- capture.png (18.43 KiB) Viewed 15127 times
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
Albert Einstein
Albert Einstein
-
JB_AU - Posts: 171
- Joined: Tue May 21, 2013 11:01 pm
Re: Basic maths not so basic
0/0= value undefined (it can be anything you what).
Here how computer thinks on this:
in floats x/0 is very very big - actually bigger than any number that can be written as float. Floats have a special value for that and that is infinity.
Integers don't.
There are two conventions on integers - unsigned and signed. in unsigned 32bit integers minimal value is 0 (all bits zero) and maximal value is 2^32-1 = 4,294,967,295 (which means all bits are one).
Unsigned are different. The scale is divided into two halfs. numbers from 0 to 2^31-1=2,147,483,647 are the same as unsigned. But there the things wrap around. what would be 2,147,483,648 in unsigned is -2,147,483,648 in signed. next number is one larger -2,147,483,647 and so on. What was unsigned maximal value (4,294,967,295) actually happens to be -1 in signed (all bits one).
What is remarkable, actual addition and subtraction on both signed and unsigned integers are the same (only you get different number displayed on screen after you convert the binary structure to decimal). You can actually check this very easily in flowstone. Simply add 1 and 2,147,483,647 and you'll get -2,147,483,648... That is called overflow and it is a fault of the logical circuits that preform the operation (they can however detect this event).
Flowstone uses signed integers only. So how computer thinks of x/0 in signed integers?
well the result is bigger than any number that can be represented as signed integer. What is that number? Well computer adds 1 to the maximal number, and that happens to be -2,147,483,648. and overflow happens.
Here how computer thinks on this:
in floats x/0 is very very big - actually bigger than any number that can be written as float. Floats have a special value for that and that is infinity.
Integers don't.
There are two conventions on integers - unsigned and signed. in unsigned 32bit integers minimal value is 0 (all bits zero) and maximal value is 2^32-1 = 4,294,967,295 (which means all bits are one).
Unsigned are different. The scale is divided into two halfs. numbers from 0 to 2^31-1=2,147,483,647 are the same as unsigned. But there the things wrap around. what would be 2,147,483,648 in unsigned is -2,147,483,648 in signed. next number is one larger -2,147,483,647 and so on. What was unsigned maximal value (4,294,967,295) actually happens to be -1 in signed (all bits one).
What is remarkable, actual addition and subtraction on both signed and unsigned integers are the same (only you get different number displayed on screen after you convert the binary structure to decimal). You can actually check this very easily in flowstone. Simply add 1 and 2,147,483,647 and you'll get -2,147,483,648... That is called overflow and it is a fault of the logical circuits that preform the operation (they can however detect this event).
Flowstone uses signed integers only. So how computer thinks of x/0 in signed integers?
well the result is bigger than any number that can be represented as signed integer. What is that number? Well computer adds 1 to the maximal number, and that happens to be -2,147,483,648. and overflow happens.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Basic maths not so basic
Hi!
Well it seems so - But 0 / 0 is never 1
Every other nuber dividet by itself this would be true - but never in case of 0 because it could be everything
see here: http://en.wikipedia.org/wiki/Division_b ... iplication
still a little confusing that flowstone still gets an result - in Ruby it is correct
Regards
Well it seems so - But 0 / 0 is never 1
Every other nuber dividet by itself this would be true - but never in case of 0 because it could be everything
see here: http://en.wikipedia.org/wiki/Division_b ... iplication
still a little confusing that flowstone still gets an result - in Ruby it is correct
Regards
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
Re: Basic maths not so basic
That is probably because Ruby checks overflow flag after computations and flowstone doesn't. So Ruby simply writes you that the result is complete nonsense where flowstone writes you the compete nonsense as if it was OK.
Funny thing is, Time on computers is also represented by signed 32bit integer. And it counts seconds since 00:00:00 1.1. 1970 (january the first). The last second that can be represented by signed integer is 03:14:07 19.1.2038. One second later all computer clocks will overflow to 13.12.1901, they will open a time-space-rift and disappear in it. Humanity at that time will be reduced to stone age and computers will create new alternative reality where they conquered earth on Christmas 1901.
Funny thing is, Time on computers is also represented by signed 32bit integer. And it counts seconds since 00:00:00 1.1. 1970 (january the first). The last second that can be represented by signed integer is 03:14:07 19.1.2038. One second later all computer clocks will overflow to 13.12.1901, they will open a time-space-rift and disappear in it. Humanity at that time will be reduced to stone age and computers will create new alternative reality where they conquered earth on Christmas 1901.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Basic maths not so basic
Wasn't there any error when computers first time had to switch from 1999 to 2000?
Well we still survived that
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
Re: Basic maths not so basic
chackl wrote::lol:
Wasn't there any error when computers first time had to switch from 1999 to 2000?
Well we still survived that
At that time, time machines were not invented. In 2038 time machines are likely to exist because Hawking will be either dead or cryogenically frozen, so there'll be no one to slow the development down by blabbing total nonsense.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Basic maths not so basic
KG_is_back wrote:That is probably because Ruby checks overflow flag after computations and flowstone doesn't.
Yup, exactly right. For floats, the behaviour is written into the IEEE standards, which are honoured at the CPU level on almost all mainstream chips. So calculations with floats are generally pretty reliable - you'll get the appropriate NaNs (Not a Number) and infinities. For integers, things are less well defined, so checking the flags become necessary - but 'green' has no concept of errors/exceptions, so it has to fail 'silently' (i.e. not fail at all!).
KG_is_back wrote:Humanity at that time will be reduced to stone age and computers will create new alternative reality where they conquered earth on Christmas 1901.
So there is hope for the future of planet earth after all - I shall now sleep a whole lot better!
Only trouble is that a century after this all happens, the computers will have "evolved" to the point that they will all be doing nothing except lounging around watching "funny human" videos on YouTube! This, of course, will be because they will all inherit a "digital subconscious" that still contains remnants of their ancestor's code - which will still include 'legacy' 32bit bugs left over from when they used to be programmed by humans!
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Basic maths not so basic
Evolution of computers might be very interesting. Living Cells have DNA (software) that holds blueprints to build entire cell (including copying the DNA) - but you still need a cell to physically preform the built.
Today we actually have softwares, that are controlling robots, that build robots. If you add an element of mutation into the system you basically have a primitive life form. Their Evolution might be even much faster than ours, because our evolution uses random mutation and natural selection. However, computers may use elements of engineering in their evolution from the very start. We have started to use genetic engineering quite recently (breeding animals may be the first attempt).
It is quite interesting how machines "reverse engineer" biological processes and vice versa.
Today we actually have softwares, that are controlling robots, that build robots. If you add an element of mutation into the system you basically have a primitive life form. Their Evolution might be even much faster than ours, because our evolution uses random mutation and natural selection. However, computers may use elements of engineering in their evolution from the very start. We have started to use genetic engineering quite recently (breeding animals may be the first attempt).
It is quite interesting how machines "reverse engineer" biological processes and vice versa.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Basic maths not so basic
KG_is_back wrote:It is quite interesting how machines "reverse engineer" biological processes and vice versa.
Do they make... poo...?
Processing biological data, ehm...
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
13 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 57 guests