Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9209959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:58:01+00:00 2026-06-18T00:58:01+00:00

I want to round off some values for my numerical calculations in views like——-

  • 0

I want to round off some values for my numerical calculations in views like——-

5.5 to 5
OR 549 t0 500 and 599 – 600 (the nearest one)

So I want to use round off OR floor function in django as we used in other languages. Is there any functions related to this in django then please suggest me some functions and also the libraries which i have to import to use these functions.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:58:02+00:00Added an answer on June 18, 2026 at 12:58 am

    Use decimal in your view:

    >>> import decimal
    >>> numbers = ['5.5','499','1','0.5']
    >>> for i in numbers:
    ...   the_number = int(decimal.Decimal(i))
    ...   if the_number / 10:
    ...      the_number = the_number + 10 - (the_number % 10)
    ...   print the_number
    ...
    5
    500
    1
    0
    

    If you want to format floats, use floatformat as suggested by Daniel, but it won’t do the rounding for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to round off my decimal values as below: 7,715.625 becomes 7,716 How
I want to round to the nearest half decimals (geo coordinates) to do some
I am developing an app and want to round off values i.e if the
Using SQL Server 2000 I want to round off the time like 01:00:00 or
I want to round numbers up to their nearest order of magnitude. (I think
I want to round off one decimal variable (ex Rs. 5.65) with 2 rules:
I want to round off a value for ex: 12.166666 ----> 12.00 12.49999 ---->
I want to be rounded off this way 13.1, round to 13.5 13.2, round
I Want to round the UITextField Corners, to display it something like this i
I want to round off a number in php, but if there is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.