Giter Club home page Giter Club logo

Comments (3)

reventlov avatar reventlov commented on May 22, 2024

Are you asking for a POPCOUNT function + a way to reinterpret_cast a bits to UInt, or something that would actually analyze the bits and only pay attention to known Flag fields?

from emboss.

fsareshwala avatar fsareshwala commented on May 22, 2024

I was asking more for a std::popcount type approach.

from emboss.

reventlov avatar reventlov commented on May 22, 2024

Adding $popcount should be straightforward: a 1-adic function that takes an integer argument. Min value is 0, max value is ciel(log2(input max val)), +1 if the input can be negative. Would need some #ifs in the C++ implementation to use std::popcount() or __builtin_popcount() where available, and fallback to a C++11 native implementation otherwise.

Internally, a bits field and a UInt field (also Flag, Int, Float, etc.) are treated similarly, so some equivalent of reinterpret_cast that basically says "pretend this field is this other type and read it out" should be doable. We would have to figure out a readable syntax -- there aren't many languages that let you cast pointers that way, so $reinterpret_cast<UInt>(field) might be the least-bad option.

from emboss.

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.