Coder Social home page Coder Social logo

64 bit integers about rcpp HOT 3 CLOSED

rcppcore avatar rcppcore commented on May 13, 2024
64 bit integers

from rcpp.

Comments (3)

romainfrancois avatar romainfrancois commented on May 13, 2024

Distinguishing at runtime based on the values would be quite expensive.

Perhaps we can emit data compatible with the bit64 package. i.e. something that looks like a numeric vector but uses the 64 bits of the double to store the 64 bits of a 64 bits integer.

from rcpp.

dselivanov avatar dselivanov commented on May 13, 2024

Just want to put here related rcpp-devel discussion (I think could be someone looking how to use bit64 with Rcpp). Mb worth to put method described by @kevinushey to Rcpp FAQ.

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
NumericVector timesTwo(NumericVector input) {

  R_xlen_t n = input.size();
  NumericVector output = no_init(n);

  long long* pInput  = (long long*) dataptr(input);
  long long* pOutput = (long long*) dataptr(output);
  for (R_xlen_t i = 0; i < n; i++)
    *pOutput++ = *pInput++ * 2;

  output.attr("class") = "integer64";
  return output;
}

/*** R
library(bit64)
object <- as.integer64(1:16)
timesTwo(object)
*/

from rcpp.

github-actions avatar github-actions commented on May 13, 2024

This issue is stale (365 days without activity) and will be closed in 31 days unless new activity is seen. Please feel free to re-open it is still a concern, possibly with additional data.

from rcpp.

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.