user4441397
user4441397

Reputation:

Keeping decimal point

Currently I have the following code:

nj_ = 0
j_ = 0
x_ = 1
nj_ = float(snum_ / (2 ** (j_ * 2)))
while nj_ > 0.4:
    nj_ = snum_ / (2 ** (j_ * 2))
    print "                         ", x_,"* sqrt(%d)" %nj_
    j_ += 1
    x_ = x_ * 2

And the output is as follows:
Finding an approximate root by factoring: the root is:

1 * sqrt(7761549)
2 * sqrt(1940387)
4 * sqrt(485096)
8 * sqrt(121274)
16 * sqrt(30318)
32 * sqrt(7579)
64 * sqrt(1894)
128 * sqrt(473)
256 * sqrt(118)
512 * sqrt(29)
1024 * sqrt(7)
2048 * sqrt(1)
4096 * sqrt(0)

How do I format the output so that it prints the actually numbers with decimal points instead of the rounding the numbers?

Upvotes: 0

Views: 33

Answers (1)

Svichkarev Anatoly
Svichkarev Anatoly

Reputation: 724

Try print line:

print "                         ", x_,"* sqrt(%0.4f)" %nj_

Upvotes: 0

Related Questions