Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Teilt a durch b und gibt das Ergebnis auf n Stellen genau an.
- global func DivideExactly(int a, int b, int n)
- {
- if(!b) return "Infinity";
- var szResult = Format("%d",a/b);
- a %= b;
- a *= 10;
- if(!a||!n) return szResult;
- else szResult = Format("%s.",szResult);
- for(; n>0; n--)
- {
- if(!a) break;
- szResult = Format("%s%d",szResult,a/b);
- a %= b;
- a *= 10;
- }
- return szResult;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement