Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
Change the value of an object to Long

I want the value of the object to be not a double type but a Long type.

client.db("customDB").collection("chart").insertMany( [{"chart": data.chart}]...


  "chart" : [ 
    {
        "x" : 1635017640000.0, ----->   1635017640000 (LONG NUMBER)
        "y" : [ 
            0.13715, 
            0.13715001, 
            0.13714999, 
            0.13715
        ]
    }
 
]  

Thank you :)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

parseInt(1635017640000.0) would be the way to go :)

No need to import anything.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

Remember to google the issue - in javascript any floating point number is called float and any number without comma is an int or rather "integer"

about 4 years ago · Juan Pablo Isaza Report

0

You can use Math.floor to convert to an integer and strip the fraction.

The Math.floor() function returns the largest integer less than or equal to a given number.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor

{
  x: Math.floor(123.456)
}

Results in

{
  x: 123
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!