Giter Club home page Giter Club logo

Comments (6)

fraillt avatar fraillt commented on July 18, 2024

This is a fundamental design decision, for cross-platform compatibility.
This is essential when serializing common types such as int, long, because these types can have different size depending on the platform.

from bitsery.

tower120 avatar tower120 commented on July 18, 2024

Well ok, long is platform dependent...
Why one can't just use int32_t, int64_t instead? They should be fixed sized.
And what about float/double?

from bitsery.

fraillt avatar fraillt commented on July 18, 2024

You should use int32_t or int64_t, but I cannot enforce it, these are alias types for fundamental numeric types (e.g. int_64t might be an alias for long or long long depending on platform.
Same with float types

from bitsery.

tower120 avatar tower120 commented on July 18, 2024

You should use int32_t or int64_t, but I cannot enforce it

I personally disagree that you should try to enforce it at library level... But that is my personal opinion.

Same with float types

There is aliases for floats? float/double have platform dependent size?

from bitsery.

fraillt avatar fraillt commented on July 18, 2024

The problem is that it is impossible to enforce to use int_32t or int. If it would be possible, then I would provide different alternatives for int_32t and int. For example: in Rust isize and i32 are different types, and float/double is IEEE 754 compatible.
Am glad that atleast in C++20 signed integers are now two's complement,
Float-types are even more trickier, theirs value representation is implementation defined, it is not even specified if they should be IEEE 754 compatible, although there are trait in numeric_limits to check if its compatbile or not is_iec559. What makes them worse, that even if they are ieee 754 compatible, it still doesn't mean that their representation would be the same on different platforms!
So my advice would be, that if you want to support all-kinds of exotic platforms, you should "quantize" all floating-point types, for example using ValueRange extension, or provide a tests so specifically for floating-point types.

from bitsery.

tower120 avatar tower120 commented on July 18, 2024

Hmm, I see...
I didn't thought that on modern CPUs, floats can have different representations...

from bitsery.

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.