Skip to content

Double precision loss on platforms with 64-bit integers on expression having ints exclusively #404

@alcz

Description

@alcz

Does not seem to be C compiler specific (other than having 64-bit ints), plus it's not Clipper compatible number scope to rely on bignum arithmetics in portable code.

  LOCAL i
   
   // intro
   ? i := - hb_HexToNum( hb_StrToHex( "ABCDEFG" ) )
   ? hb_HexToStr( hb_NumToHex( Abs( i ) ) ) // -> ABCDEFG

   ? i := hb_HexToNum( hb_StrToHex( "ABCDEFG" ) ) * -1
   ? hb_HexToStr( hb_NumToHex( Abs( i ) ) ) // -> ABCDEFH (surprise)

   // plain tests
   i := 18368730161825351 
   ? i * -1        // -18368730161825352
   ? Int( i ) * -1 // -18368730161825352
   ? - i           // -18368730161825351

   // with precompiled constants does not happen
   ? 18368730161825351 * -1 // -18368730161825351
   ? - 18368730161825351    // -18368730161825351

https://os.allcom.pl/hb/#!eJydUttOwkAQfecrTnhqTRosCBITNQgqJkQf5N20ZaGbtLvNzhbx753tBYmIMW7TtDM5t80MgMXLdLKA7ABwb6-HmS7jTKAwIpEktUKmicDfIovsWpuc8C5titFFEEsLqazYCFMhxI5ZVJG4TVwnWUlyK7KPRnylBUFpCxIih9WIBaZIdF7ITBhQwaZrmcDTNuXappFCGm2l2hz4kd9p5Lgw2v3fQuLqGgHS-G0udkv9XOaeK16tWWrueOhO7qaz-4fHLnz4NacFM6gCM6kBT2LyWNKvHjYKbtDQOwd2fzTDGYLw345zeFSawkgS-3vzKKSCFWTJdaow4XgwGl8OzsNROO4PB8MQbVJnj-Y45e_Ifg18UrZOUOF_AQaM-jo_AcM2aLUpbpXqCa941Ips5JZjvwppVBRC1dLHlzgZJmzDHHNOpvoESy7E6w

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions