Answered # Division between two integers and float result

wildgoose 420 Discussion Starter nunos Discussion Starter nunos jlm699 320 vegaseat 1,720 Discussion Starter nunos Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

No matter how you do it, the fraction part is the result of the remainder / divisor so still need a division!

Could fake it somewhat.

In integer

part %

----- = -------

whole 100

So could calculate a whole integer form of the remainder and stick your own decimal point as a string character!

(4 * 100) / 5 = 80

4 / 5 = 0

"0" "." "80" 0.80

0

No matter how you do it, the fraction part is the result of the remainder / divisor so still need a division!

Could fake it somewhat.

In integer

part %

----- = -------

whole 100So could calculate a whole integer form of the remainder and stick your own decimal point as a string character!

(4 * 100) / 5 = 80

4 / 5 = 0

"0" "." "80" 0.80

I was just wondering if there was any other way other than "from __future__ import division" because further in the program I might want to have 4/5 = 0, and because of that I won't.

Is it possible to unload from __future__ import division?

0

No idea. Sorry!

I guess I will have to do the .0 'trick'. Maybe some other folk will know a way.

Thanks wildgoose for your help.

0

I guess I will have to do the .0 'trick'. Maybe some other folk will know a way.

Thanks wildgoose for your help.

You could do this:

`float(4)/5`

Or if you wanted to perform the `from __future__ import division`

and still get integer returns you could simply turn the answer into an int like this:

```
>>> ans = 5 / 2
>>> ans
2.5
>>> int(ans)
2
>>>
```

0

You could update to Python 3.1 where '/' is the floatingpoint division and '//' is the integer division.

Actually, with Python2 versions, 4./5 would be simpler to type then 4.0/5 or float(4)/5 :)

0

You could update to Python 3.1 where '/' is the floatingpoint division and '//' is the integer division.

Actually, with Python2 versions, 4./5 would be simpler to type then 4.0/5 or float(4)/5 :)

Thanks for the two tips. I will keep that in mind.

Cheers :icon_wink:

This question has already been answered. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...