Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Highlighted
##

how do do unsigned int multiply without it rounding on ARM processors?

Participant
,

Dec 12, 2015

Copy link to clipboard

Copied

I have encountered a very tricky issue, that I AM SURE has bitten many a person in the ass, and that is assuming that you can multiply two 32-bit unsigned numbers, and get the 32 bit quotient, (the 32 least significant bits) without any rounding going on. It works fine on Intel chips, because A*B is converted to a floating multiply by the Ecmascript spec (why did they do this one wonders!), and since on intel chips you have 80 bits of precision, there is no problem with the conversion to and from 80 bit floating point. But when you try running your code on android, you get a rounding error, and if like me you are trying to do a hashing function that depends on perfect arithmetic, you are screwed!

Unfortunately, on ARM tablets such as Trasnformer Prime, and others, there is a loss of precision. This is deadly for hashing algorithms, random number generators, any other function that is expecting full 32 bit x 32 bit = 32 bit result with higher order bits ignored.

var a : uint = 0xaf1ac315;

var b : uint = 0x01000193;

var c : uint = uint(a*b);

the answer in 64 bit arithmetic would be 0xaf1bc6bc211a0f

on 64 bit intel CPU, you will get bc211a0f (correct, least significant 32 bits)

on ARM CPU, you will get bc211a10 (rounded answer due to loss of precision)

i have yet to figure out how to get AS3 to correctly multiply two integers without screwing it up on the ARM CPU platform.

Perhaps some clever person knows a function in the AS3 runtime that will allow you to multiply two unsigned integers without converting to floating point, which on the ARM architecture is a measly 64 bits.

TOPICS

Performance issues

Community Guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

how do do unsigned int multiply without it rounding on ARM processors?

Participant
,

Dec 12, 2015

Copy link to clipboard

Copied

I have encountered a very tricky issue, that I AM SURE has bitten many a person in the ass, and that is assuming that you can multiply two 32-bit unsigned numbers, and get the 32 bit quotient, (the 32 least significant bits) without any rounding going on. It works fine on Intel chips, because A*B is converted to a floating multiply by the Ecmascript spec (why did they do this one wonders!), and since on intel chips you have 80 bits of precision, there is no problem with the conversion to and from 80 bit floating point. But when you try running your code on android, you get a rounding error, and if like me you are trying to do a hashing function that depends on perfect arithmetic, you are screwed!

Unfortunately, on ARM tablets such as Trasnformer Prime, and others, there is a loss of precision. This is deadly for hashing algorithms, random number generators, any other function that is expecting full 32 bit x 32 bit = 32 bit result with higher order bits ignored.

var a : uint = 0xaf1ac315;

var b : uint = 0x01000193;

var c : uint = uint(a*b);

the answer in 64 bit arithmetic would be 0xaf1bc6bc211a0f

on 64 bit intel CPU, you will get bc211a0f (correct, least significant 32 bits)

on ARM CPU, you will get bc211a10 (rounded answer due to loss of precision)

i have yet to figure out how to get AS3 to correctly multiply two integers without screwing it up on the ARM CPU platform.

Perhaps some clever person knows a function in the AS3 runtime that will allow you to multiply two unsigned integers without converting to floating point, which on the ARM architecture is a measly 64 bits.

TOPICS

Performance issues

Community Guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

magicmouse

Dec 12, 2015
0
/t5/air/how-do-do-unsigned-int-multiply-without-it-rounding-on-arm-processors/td-p/7868431
Have something to add?

Join the conversation

Using the Community
Experience League
Terms of Use
Privacy Policy
Cookie preferences
AdChoices
Language:

- Deutsch
- English
- Español
- Français
- 日本語コミュニティ
- Português

Copyright © 2020 Adobe. All rights reserved.