Python Forum
Storing float as integer in a database
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Storing float as integer in a database
#4
I don't know about names. We did this at my old job with survey weights, but I'm not aware of any commonly used terms for it. How about a generalized form called int_power:

def int_power(n, pow):
    if pow >= 0:
        return int(round(n * 10 ** pow, 0))
    else:
        return n * 10 ** pow
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Storing float as integer in a database - by Ageir - Aug-15-2017, 04:25 PM
RE: Storing float as integer in a database - by ichabod801 - Aug-15-2017, 07:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python calculate float plus float is incorrect? sirocawa 6 456 Apr-16-2024, 01:45 PM
Last Post: DeaD_EyE
  How to check if user entered string or integer or float?? prateek3 5 11,422 Dec-21-2019, 06:24 PM
Last Post: DreamingInsanity
  Converting float (2.0) to integer(2) Raj_Kumar 2 2,562 Dec-07-2019, 11:01 AM
Last Post: DeaD_EyE
  Comaparing Float Values of Dictionary Against A Float Value & Pick Matching Key firebird 2 3,444 Jul-25-2019, 11:32 PM
Last Post: scidam
  storing input as a integer help faputting 1 2,491 Feb-23-2018, 06:39 PM
Last Post: nilamo
  cannot convert float infinity to integer error despite rounding off floats Afterdarkreader 3 15,295 Dec-15-2017, 02:01 AM
Last Post: micseydel
  Taking user input and storing that to a variable then storing that variable to a list jowalk 12 37,493 Mar-27-2017, 11:45 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020