Giter VIP home page Giter VIP logo

Comments (5)

milancurcic avatar milancurcic commented on July 23, 2024 1

This is fixed in latest relase: https://github.com/wavebitscientific/datetime-fortran/releases/tag/v1.6.1. Thanks @alexavr.

from datetime-fortran.

milancurcic avatar milancurcic commented on July 23, 2024

Hi alexavr, great catch! I can reproduce this.

No compiler promotion for all integers is necessary. The addition of integers goes left-to-right here (even though not defined by the standard and compiler-dependent), so integer overflow occurs before we get to multiplying with milliseconds.

The correct and easy solution IMO is to multiply with a 64-bit float at the start:

  total_seconds = 1._real64 * self % days*86400 + self % hours*3600&
                + self % minutes*60 + self % seconds   &
                + self % milliseconds*1e-3_real64

I tested this with your program. With this solution, we can work with 32-bit integers and floats for most stuff, and use 64-bit where needed.

from datetime-fortran.

alexavr avatar alexavr commented on July 23, 2024

Very good idea!
Works for me.
Appreciated!

from datetime-fortran.

milancurcic avatar milancurcic commented on July 23, 2024

Do you mind submitting this fix as a PR?

  1. Fork this repo
  2. git clone https://github.com/alexavr/datetime-fortran
  3. Make your changes
  4. git add, commit, and push to alexavr/datetime-fortran
  5. Open Pull Request from your repo page.

from datetime-fortran.

alexavr avatar alexavr commented on July 23, 2024

Are you kidding? I'll be honored!
Give me some little time to learn how to do that LOL

from datetime-fortran.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.