Numeric Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the subclasses of numeric datatype?

A

Integer,Float,BigDecimal,Complex,Rational

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In earlier versions of Ruby Integer further divided into two types? True or false

A

True - Fixnum and Bignum

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write the methods for

a) even check
b) odd check
c) zero check
d) integer check

A

n. even?
n. odd?
n. zero?
n. integer?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Write the methods to find gcd,lcm and both?

A

n. lcm
n. gcd
n. gcdlcm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain pred and succ methods

A

n. pred will print preceeder

n. succ will print successor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the methods related to fraction in float class?

A

Denominator and numerator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What round method will do in float class?

A

Either it will roundoff or roundup the nearest value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

To print next high value , to print previous low value what are the methods used in Float?

A

ceil

float

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What “quo” method will do in Rational?

A

It will perform division

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the use of truncate method in BigDecimal?

A

It will truncate all the values after the dot and return integer value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain magnitude method in Rational?

A

same as abs method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you check the number is Positive or not?

A

positive? negative?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the use of abs2 method?

A

Complex(5).abs2 => gives square of the result

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain conjugate method in Complex?

A

Complex(1, 2).conjugate #=> (1-2i)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to get the imaginary part of complex numbers

A

Complex(9, -4).imaginary #=> -4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly