QUICK REFERENCE: MATHEMATICS

Unlike some other languages, Smalltalk don't have a Class Math. Like "all is an object" is the Smalltalk paradigma, we use the number like a prefix for some methods:


rounded

Example

nH1:=   6.68 rounded.
nH2:=   6.48 rounded.
Transcript show:nH1.
Transcript show:'----'.
Transcript show:nH2 

Result

7----6


floor


ceiling

Example

nX1:=   6.68 floor.
nX2 :=   6.48 ceiling.
Transcript show:nX1.
Transcript show:'----'.
Transcript show:nX2 

Result

6----7


sqrt

Example

nQ:= 9 sqrt.
Transcript show:nQ.
  

Result

3.0


abs

Example

nA:=   -2 abs.   
Transcript show:nA
  

Result

2


raisedTo:n

Example

nH1:=   3 raisedTo: 3.  
Transcript show:nH1.
 
  

Result

27


sin

Sin of a angle in radians. If you have a value in degrees - 90 - look the formula in the sample.

Example

nH1:=   ((90*3.1416/180)sin)rounded.  
Transcript show:nH1.
 
 
  

Result

1


cos


tan


sin


arcSin


arcCos


arcTan


max

If you need to find the maxime value of a group of numbers you need to use an Ordered Collection:

Example

| oC m |
oC:= OrderedCollection new.
oC add: 7.
oC add: 9.
 m:= oC max.
Transcript show:m
 
 
  

Result

9


min

If you need to find the minimum value of a group of numbers you need to use an Ordered Collection:

Example

| oC m |
oC:= OrderedCollection new.
oC add: 7.
oC add: 9.
 m:= oC min.
Transcript show:m
 
 
  

Result

7



PREVIOUS LESSON NEXT LESSON
TABLE OF CONTENTS HOMEPAGE