This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-05-04 01:54:35

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Some Math functions that are VERY VERY MUCH NEEDED!

I suggest

Math.ceil() and Math.floor() functions to be added to math functions in scratch2.0 (i know this is last minute advice but still they are very very useful)


For those who dont know what Math.ceil() and Math.Floor() functions are, Math.floor() gives the greatest integer which is less the given number

say

Math.floor(2.5) = 2
Math.floor(2.9) = 2

and Math.ceil() is reverse of Math.floor() :: i.e; it gives the smallest integer greater then the given integer

Math.ceil(3.1) = 3
Math.ceil(3.6) = 3


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#2 2011-05-04 02:00:30

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

Meet the <round( [/blocks] block.  tongue

Offline

 

#3 2011-05-04 08:43:04

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

scimonster wrote:

Meet the <round( [/blocks] block.  tongue

Round block is USELESS!

I mean declare a 2 dimensional array by making a single array Row major and then u will find out why i actually need floor and ceil... o btw its also a feature in 99.999% of coding languages  tongue  C , C++ , C# , D , Python .. each nd everything has a feature like that

the difference between Ceil / Floor and Round block is ::

Round will give closest integer regardless if its greater or smaller  tongue 

and to make something like ceil u will have to do

if(Round(X) < X)
{
X = Round(X) +1;
}
else
{
X = Round(X) ;
}

Which SLOWS DOWN YOUR PROGRAM!!!!!

Last edited by fanofcena (2011-05-04 08:51:47)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#4 2011-05-04 08:48:03

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

fanofcena wrote:

scimonster wrote:

Meet the <round( [/blocks] block.  tongue

Round block is USELESS!

I mean declare a 2 dimensional array by making a single array Row major and then u will find out why i actually need floor and ceil... o btw its also a feature in 99.999% of coding languages  tongue  C , C++ , C# , D , Python .. each nd everything has a feature like that

the difference between Ceil / Floor and Round block is ::

Round will give closest integer regardless if its greater or smaller  tongue 

and to make something like ceil u will have to do

if(Round(X) < X)
{
X = Round(X) +1;
}
else
{
X = Round(X) ;
}

Which SLOWS DOWN YOUR PROGRAM!!!!!

I knew about the code you told me.
I also know that it slows down the program.
However, I don't think the Scratch Team wants to add a million blocks into Scratch 2.0  hmm

Offline

 

#5 2011-05-04 08:51:17

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

scimonster wrote:

fanofcena wrote:

scimonster wrote:

Meet the <round( [/blocks] block.  tongue

Round block is USELESS!

I mean declare a 2 dimensional array by making a single array Row major and then u will find out why i actually need floor and ceil... o btw its also a feature in 99.999% of coding languages  tongue  C , C++ , C# , D , Python .. each nd everything has a feature like that

the difference between Ceil / Floor and Round block is ::

Round will give closest integer regardless if its greater or smaller  tongue 

and to make something like ceil u will have to do

if(Round(X) < X)
{
X = Round(X) +1;
}
else
{
X = Round(X) ;
}

Which SLOWS DOWN YOUR PROGRAM!!!!!

I knew about the code you told me.
I also know that it slows down the program.
However, I don't think the Scratch Team wants to add a million blocks into Scratch 2.0  hmm

I think this block is needed lol


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#6 2011-05-04 19:07:26

ihaveamac
Scratcher
Registered: 2007-09-22
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

scimonster wrote:

fanofcena wrote:

scimonster wrote:

Meet the <round( [/blocks] block.  tongue

Round block is USELESS!

I mean declare a 2 dimensional array by making a single array Row major and then u will find out why i actually need floor and ceil... o btw its also a feature in 99.999% of coding languages  tongue  C , C++ , C# , D , Python .. each nd everything has a feature like that

the difference between Ceil / Floor and Round block is ::

Round will give closest integer regardless if its greater or smaller  tongue 

and to make something like ceil u will have to do

if(Round(X) < X)
{
X = Round(X) +1;
}
else
{
X = Round(X) ;
}

Which SLOWS DOWN YOUR PROGRAM!!!!!

I knew about the code you told me.
I also know that it slows down the program.
However, I don't think the Scratch Team wants to add a million blocks into Scratch 2.0  hmm

They can combine these functions into one block.


~ihaveamac - visit ihaveamac.net

Offline

 

#7 2011-05-04 19:38:14

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

You can actually replicate this with the round block pretty easily. Math.floor( ) would be [Round ( ) - 0.5], and Math.ceil( ) would be [Round ( ) + 0.5].


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#8 2011-05-05 00:27:14

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

Harakou wrote:

You can actually replicate this with the round block pretty easily. Math.floor( ) would be [Round ( ) - 0.5], and Math.ceil( ) would be [Round ( ) + 0.5].

I know but wont it slow down ??? a bit ???


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#9 2011-05-05 02:42:34

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

nope[Round ( ) - 0.5], [Round ( ) + 0.5] are perfect substitutes. What is more needed is ATAN2, aside from that scratch pretty much has all the math functions it needs.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#10 2011-05-05 09:45:53

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

I just have a question:

Is asin the same thing as sin-1 or cosecant?

Offline

 

#11 2011-05-05 10:06:34

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

Actually, for the one that turns 3.6 into 3, you could do: (letter 1 of number). It works for single digits, but for 40.2, you need to do (join (letter 1 of number) (letter 2 of number) and so on for triple-digits etc.

Offline

 

#12 2011-05-06 01:18:32

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

archmage wrote:

nope[Round ( ) - 0.5], [Round ( ) + 0.5] are perfect substitutes. What is more needed is ATAN2, aside from that scratch pretty much has all the math functions it needs.

Ah yes sir!!!!!!!!!!!!!!!!!!! Atan2 is really needed!! (actually they should add something like Header files in C++ and leave us to create atomic blocks as perneed lol)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#13 2011-05-07 08:42:52

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

Actually, for the one that turns 3.6 into 3, you could do: (letter 1 of number). It works for single digits, but for 40.2, you need to do (join (letter 1 of number) (letter 2 of number) and so on for triple-digits etc.

Meet the (rdococ's solution) block, as it reports what's in the quote.

Offline

 

#14 2011-05-07 10:35:53

LolCat72
Scratcher
Registered: 2010-04-18
Posts: 100+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

I think we should have a percent of block.

Example:
()% of ()

if answer= (p)% of (b)
(whatever happens when you get the problem right)
else
(whatever happens when you get the problem wrong)

My little brother is in fourth grade and my little sister is in fifth and it would be very useful to make learning percents fun for them! That way, I could add percents to my math games.

Last edited by LolCat72 (2011-05-07 10:37:17)


Please think twice before printing this post, as you are saving the Earth, the only planet with bacon.

Offline

 

#15 2011-05-07 13:00:45

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

LolCat72 wrote:

I think we should have a percent of block.

Example:
()% of ()

if answer= (p)% of (b)
(whatever happens when you get the problem right)
else
(whatever happens when you get the problem wrong)

My little brother is in fourth grade and my little sister is in fifth and it would be very useful to make learning percents fun for them! That way, I could add percents to my math games.

But that's not that hard to make... just use if (answer)/(b) = (p).


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#16 2011-05-07 17:48:11

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

If you're saying it's easy to go without, why do we have forever if?


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#17 2011-05-07 19:39:11

LolCat72
Scratcher
Registered: 2010-04-18
Posts: 100+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

Harakou wrote:

LolCat72 wrote:

I think we should have a percent of block.

Example:
()% of ()

if answer= (p)% of (b)
(whatever happens when you get the problem right)
else
(whatever happens when you get the problem wrong)

My little brother is in fourth grade and my little sister is in fifth and it would be very useful to make learning percents fun for them! That way, I could add percents to my math games.

But that's not that hard to make... just use if (answer)/(b) = (p).

Huh? Why does that work? What does that have to do with percents?
EDIT: Nevermind, I see  smile

Last edited by LolCat72 (2011-05-07 19:41:23)


Please think twice before printing this post, as you are saving the Earth, the only planet with bacon.

Offline

 

#18 2011-05-09 09:04:27

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Some Math functions that are VERY VERY MUCH NEEDED!

juststickman wrote:

If you're saying it's easy to go without, why do we have forever if?

I don't know.

Offline

 

Board footer