Round off function in python Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Why are floating point numbers inaccurate?Rounding floats with representation error to the closest and correct resultTesting for rounding errors due to Floating Point limitationsHow can I represent an 'Enum' in Python?How to flush output of print function?Rounding decimals with new Python format functionWay to create multiline comments in Python?What is the Python 3 equivalent of “python -m SimpleHTTPServer”Python 3.x rounding behaviorHow to use filter, map, and reduce in Python 3What does -> mean in Python function definitions?Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?Are dictionaries ordered in Python 3.6+?

What is /etc/mtab in Linux?

What's the difference between using dependency injection with a container and using a service locator?

Can you stand up from being prone using Skirmisher outside of your turn?

My bank got bought out, am I now going to have to start filing tax returns in a different state?

Align column where each cell has two decimals with siunitx

Putting Ant-Man on house arrest

Would reducing the reference voltage of an ADC have any effect on accuracy?

The art of proof summarizing. Are there known rules, or is it a purely common sense matter?

Why does the Cisco show run command not show the full version, while the show version command does?

Map material from china not allowed to leave the country

Additive group of local rings

Is Electric Central Heating worth it if using Solar Panels?

Does the set of sets which are elements of every set exist?

How long after the last departure shall the airport stay open for an emergency return?

Retract an already submitted recommendation letter (written for an undergrad student)

With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space

Do you need a weapon for Thunderous Smite, and the other 'Smite' spells?

Why did C use the -> operator instead of reusing the . operator?

As an international instructor, should I openly talk about my accent?

How to keep bees out of canned beverages?

How to count in linear time worst-case?

A Paper Record is What I Hamper

All ASCII characters with a given bit count

Has a Nobel Peace laureate ever been accused of war crimes?



Round off function in python



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Why are floating point numbers inaccurate?Rounding floats with representation error to the closest and correct resultTesting for rounding errors due to Floating Point limitationsHow can I represent an 'Enum' in Python?How to flush output of print function?Rounding decimals with new Python format functionWay to create multiline comments in Python?What is the Python 3 equivalent of “python -m SimpleHTTPServer”Python 3.x rounding behaviorHow to use filter, map, and reduce in Python 3What does -> mean in Python function definitions?Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?Are dictionaries ordered in Python 3.6+?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















The round function seems pretty tricky in python.
For round(51.665,2) it shows 51.66
and for round(51.765,2) it shows 51.77.
Why is it so?enter image description here










share|improve this question

















  • 1





    Don't post images use text.

    – AkshayNevrekar
    Mar 9 at 5:54











  • docs.python.org/2/library/functions.html#round. It may help you.

    – Ghantey
    Mar 9 at 6:02

















0















The round function seems pretty tricky in python.
For round(51.665,2) it shows 51.66
and for round(51.765,2) it shows 51.77.
Why is it so?enter image description here










share|improve this question

















  • 1





    Don't post images use text.

    – AkshayNevrekar
    Mar 9 at 5:54











  • docs.python.org/2/library/functions.html#round. It may help you.

    – Ghantey
    Mar 9 at 6:02













0












0








0








The round function seems pretty tricky in python.
For round(51.665,2) it shows 51.66
and for round(51.765,2) it shows 51.77.
Why is it so?enter image description here










share|improve this question














The round function seems pretty tricky in python.
For round(51.665,2) it shows 51.66
and for round(51.765,2) it shows 51.77.
Why is it so?enter image description here







python-3.x






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 9 at 5:52









Shubhankar SoniShubhankar Soni

1




1







  • 1





    Don't post images use text.

    – AkshayNevrekar
    Mar 9 at 5:54











  • docs.python.org/2/library/functions.html#round. It may help you.

    – Ghantey
    Mar 9 at 6:02












  • 1





    Don't post images use text.

    – AkshayNevrekar
    Mar 9 at 5:54











  • docs.python.org/2/library/functions.html#round. It may help you.

    – Ghantey
    Mar 9 at 6:02







1




1





Don't post images use text.

– AkshayNevrekar
Mar 9 at 5:54





Don't post images use text.

– AkshayNevrekar
Mar 9 at 5:54













docs.python.org/2/library/functions.html#round. It may help you.

– Ghantey
Mar 9 at 6:02





docs.python.org/2/library/functions.html#round. It may help you.

– Ghantey
Mar 9 at 6:02












1 Answer
1






active

oldest

votes


















0














This is related to in binary representation of floating point numbers (numbers in base 10 are sometimes imprecisely represented in base 2). The rationale is more thoroughly described in this answer and this one. More theoretically: What causes floating point rounding errors?



Important thing to note is that Python interpreter displays rounded floating point numbers.






share|improve this answer























  • If the answer helped you please consider accepting it (the gray tick mark besides the up/down vote on the left of the answer).

    – sophros
    Mar 10 at 15:19











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074428%2fround-off-function-in-python%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














This is related to in binary representation of floating point numbers (numbers in base 10 are sometimes imprecisely represented in base 2). The rationale is more thoroughly described in this answer and this one. More theoretically: What causes floating point rounding errors?



Important thing to note is that Python interpreter displays rounded floating point numbers.






share|improve this answer























  • If the answer helped you please consider accepting it (the gray tick mark besides the up/down vote on the left of the answer).

    – sophros
    Mar 10 at 15:19















0














This is related to in binary representation of floating point numbers (numbers in base 10 are sometimes imprecisely represented in base 2). The rationale is more thoroughly described in this answer and this one. More theoretically: What causes floating point rounding errors?



Important thing to note is that Python interpreter displays rounded floating point numbers.






share|improve this answer























  • If the answer helped you please consider accepting it (the gray tick mark besides the up/down vote on the left of the answer).

    – sophros
    Mar 10 at 15:19













0












0








0







This is related to in binary representation of floating point numbers (numbers in base 10 are sometimes imprecisely represented in base 2). The rationale is more thoroughly described in this answer and this one. More theoretically: What causes floating point rounding errors?



Important thing to note is that Python interpreter displays rounded floating point numbers.






share|improve this answer













This is related to in binary representation of floating point numbers (numbers in base 10 are sometimes imprecisely represented in base 2). The rationale is more thoroughly described in this answer and this one. More theoretically: What causes floating point rounding errors?



Important thing to note is that Python interpreter displays rounded floating point numbers.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 9 at 6:05









sophrossophros

3,00411135




3,00411135












  • If the answer helped you please consider accepting it (the gray tick mark besides the up/down vote on the left of the answer).

    – sophros
    Mar 10 at 15:19

















  • If the answer helped you please consider accepting it (the gray tick mark besides the up/down vote on the left of the answer).

    – sophros
    Mar 10 at 15:19
















If the answer helped you please consider accepting it (the gray tick mark besides the up/down vote on the left of the answer).

– sophros
Mar 10 at 15:19





If the answer helped you please consider accepting it (the gray tick mark besides the up/down vote on the left of the answer).

– sophros
Mar 10 at 15:19



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074428%2fround-off-function-in-python%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович