Question: are Math.getExponent and Math.scalb supported on Android?

by Danke Xie » Thu, 12 Aug 2010 05:06:12 GMT


Sponsored Links
 Hi,

As an experiment, I am trying to port a virtual machine written in
Java to Android platform. However, it heavily uses some special
floating point functions, like getting the exponent, or multiplying a
floating point by a power of 2. These are done with new Java Math
functions scalb and getExponent. It appears that they can be done by
manipulating the binary representation of the floating points.
However, because these functions don't seem to be available on Android
yet (are they?), all I could think of is implementing them with other
functions, like

public static float scalb(float f, int scaleFactor) {
  return f * Math.pow(2, scaleFactor);
}

public static int getExponent(float f) {
  return (int) (Math.log(f)/Math.log(2));
}

The question is... if the library doesn't have stock scalb and
getExponent functions, but the code is compiled with a new Java SDK
supporting the new math functions, could the Java compiler still
figure out a way to optimize these functions and operate on the binary
numeric level?

Thanks,
Danke

--



Other Threads

1. SE arc

Sayang menurut sy ...body nya bagusan X10i nya, Internal Mem kecil, 
Display bawa2 Bravia Engine......beda tipis sama TFT :P


Hrg sekarang banyak yg nyaingin..... :P


Jus*
/motorola_verizon_powered_by_smart/
|| dari pc windows xp original ||
~ my porfolio foto http://www.firnaglass.com/ ~







-- ===============

2. alloc buffer size for video

I'm encoding a video but I need to find which buffer size I should
allocate for the video.. I found a code but 100000 isn't enough for
some videos with large size. HOw can I find the optimum size?

And I couldn't understand how I can allocate a buffer size for a
video? Which preferences of a video or frame should I be interested
for that purpose ?

Thanks

Here is my code;

static void open_video(AVFormatContext *oc, AVStream *st)
{
    AVCodec *codec;
    AVCodecContext *c;

    c = st->codec;

    /* find the video encoder */
    codec = avcodec_find_encoder(c->codec_id);
    if (!codec) {
        fprintf(stderr, "codec not found\n");
        exit(1);
    }

    /* open the codec */
    if (avcodec_open(c, codec) < 0) {
        fprintf(stderr, "could not open codec\n");
        exit(1);
    }

    video_outbuf = NULL;
    if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) {
        /* allocate output buffer */
        /* XXX: API change will be done */
        /* buffers passed into lav* can be allocated any way you
prefer,
           as long as they're aligned enough for the architecture, and
           they're freed appropriately (such as using av_free for
buffers
           allocated with av_malloc) */
        video_outbuf_size =100000;

        video_outbuf = av_malloc(video_outbuf_size);
    }
    /* allocate the encoded raw picture */
    picture = alloc_picture(c->pix_fmt, c->width, c->height);
    if (!picture) {
        fprintf(stderr, "Could not allocate picture\n");
        exit(1);
    }
}

-- 

3. Multiple copies of same resource in different folders

4. [Advice] Best way to handle background process

5. RTSP lag

6. jQuery Failed to Append DOM in Android Emulator

7. How to finger-draw over Picture and save painting only?