> Does v8 internally promote the int32 to a double during Integer::New()?
Sometimes :-) Internally numbers in V8 can be represented in two forms: - as so called SMall Integer or smi (31-bit on ia32 and ARM, 32-bit on x64; passed as immediate value); - HeapNumber (double allocated in the heap and passed by reference). If value you pass into Integer::New fits into smi-representation V8 will store it as a smi otherwise it will allocate a HeapNumber. > maybe I'm looking in the wrong place v8::Integer::New is defined in api.cc You can also check the comment in the beginning of objects.h for details about object representation. -- Vyacheslav Egorov On Tue, Dec 14, 2010 at 5:38 PM, Jeremy <[email protected]> wrote: > On Dec 14, 2:02 am, Vyacheslav Egorov <[email protected]> wrote: >> Hi Jeremy, >> >> There is no integer type in JavaScript. >> >> There is Number type which is defined to be double precision >> floating-point number. >> >> ECMA-262 defined ToInteger(x) operation in section 9.2: roughly it is >> just sign(x) * floor(abs(x)) plus several special cases for NaN, -0, >> and infinities. >> >> Integer type in V8 API should be treated as a convenient way of >> representing and accessing result of this operation. It does not >> extend underlying JavaScript type system, it just wraps value of >> Number type. >> > > Thanks for your reply. Does v8 internally promote the int32 to a > double during Integer::New()? What about Int32? I tried to look this > up in the source but I can't make heads or tails of it (or maybe I'm > looking in the wrong place). > > Jeremy > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
