Live data from Hacker News

BigInt Shipping in Firefox

wingolog.org

91–100 of 172 posts

Re: BigInt Shipping in Firefox

#91
post #71

Earlier quoted context omitted.

I don't know if that follows. I think it's reasonable to expect a piece of code that works with integer numbers to also work with bigints. But it's not really reasonable to expect it to work with anything that closely resembles a number. That sort of weak typing is much more problematic and should be avoided. But I dunno, maybe it shouldn't be expected to work with bigints either. It's not a regular int, so I doubt p…

Well, bigints are fine as array indices. However they are not interoperable with numbers in any type of arithmetic. I don't think it's reasonable to expect to use bigints in any place where one uses numbers. "Regular int" is not a distinct type in javascript. There are now two numeric types: 64-bit floating point, and bigint.

Obligatory informational: JavaScript numbers are IEEE-754 standard. You get 53 bits of precision, but can still represent other numbers outside that range, and there are the usual issues relating to dealing with floats.

    Math.pow(2,53)
    // 9007199254740992
    Math.pow(2,53)+1
    // 9007199254740992
    Math.pow(2,53)+2
    // 9007199254740994
    0.1 + 0.2
    // 0.30000000000000004

Re: BigInt Shipping in Firefox

#92
can it represent and manipulate ipv6 addresses (128 bit quantities) efficiently? not having to split into two 64 bits or deal with them as bit-strings may be an improvement for some things

Re: BigInt Shipping in Firefox

#93

BitInt's "n" suffix appears to stand for "numeric", but that seems confusing when typeof 1 === "number" and typeof 1n === "bigint" . Why not an "i" suffix for "integer"? I understand that a "b" suffix is probably reserved in case JavaScript adds support for binary literals. https://tc39.github.io/proposal-bigint/#prod-BigIntLiteralSu...

'i' suffix are often used in languages for complex numbers. For example, in ruby '1i' evaluates to 0+1i as a complex number.

I suspect they didn't want to conflate the two types.

Re: BigInt Shipping in Firefox

#94
post #67

Earlier quoted context omitted.

Because number is practically the same as double, and you can't just go and change double values to integer values. Also, doubles are fast. BigInts are not.

Python has only Number though, and that can get as large as fits in your memory. Not sure why they didn't ship this with decimals and enabled it by default in javascript. I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3). It was basically remembering the sign and handling some other notation like 1e100, splitting on the dot, and adding them up the no…

Decimals are conceptually similar to binary numbers, just with a different base. So no, they can’t represent all rationals accurately, and yes, they involve approximation.

For example, you can’t represent 1/3 in decimal, for the exact same reason you can’t represent 1/5 in binary. (1/3 is the infinitely repeating decimal 0.3333..., whereas 1/5 is the infinitely repeating binary 0.00110011001100...)

In general if you need to perfectly represent rational arithmetic you shouldn’t be using decimal or binary; you should have a type with an integer numerator and integer denominator. I don’t see the value of making arithmetic dramatically slower without actually solving the approximation issue.

If you are ever calling == on floating point numbers, you are doing something seriously wrong. Floating point numbers are supposed to be used for scientific and numerical computations where there is a notion of measurement error, and “exactly equal” is nonsense, so yes, speed is the entire point.

That’s why making a language without integers is such a serious mistake.

Re: BigInt Shipping in Firefox

#95
post #67

Earlier quoted context omitted.

Because number is practically the same as double, and you can't just go and change double values to integer values. Also, doubles are fast. BigInts are not.

Python has only Number though, and that can get as large as fits in your memory. Not sure why they didn't ship this with decimals and enabled it by default in javascript. I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3). It was basically remembering the sign and handling some other notation like 1e100, splitting on the dot, and adding them up the no…

> Python has only Number though, and that can get as large as fits in your memory.

This is not true.

    >>> type(1)
    
    >>> type(1.5)
    

Re: BigInt Shipping in Firefox

#96

I can't wait to kick the tires on this feature. I wonder how it compares to the integer implementation in WebAssembly.

WebAssembly has not arbitrary precision integers, so presumably is able to execute arithmetic as direct hardware instructions. bigint, on the other hand, is arbitrary precision, so it obviously can't do that.

Re: BigInt Shipping in Firefox

#98
post #55
post #35

Earlier quoted context omitted.

I think the comment has been deleted, do you remember what it was?

Basically, somebody left a comment saying the author was wrong and didn't know what he was talking about in a very aggressive way without demonstrating where it was wrong and why. Sorry for the drama. I know its off topic, but its all I can contribute since I know very little about the implementation of base data types.

Andy has previously had some asshats telling him he's wrong on things where he obviously is not. I don't know if there is one individual that holds a grudge or if he attracts an annoying number of know-it-alls.

Re: BigInt Shipping in Firefox

#99
post #43

Kind of bummed this is a new primitive type. Every instance of `typeof a === 'number'` just became `typeof a === `number` || typeof a === 'bigint'`... EDIT: The more I think about it (and the more comments I get), the more I think this might actually be a good thing. I think bigint will probably not be used in places where integer numbers are currently used, and it might be unreasonable to expect code to work with nu…

The more I think about about it the less I like this new feature. They should have implemented BigInt as a class instead and rely on a transcoder to make algorithms easier to write.

Re: BigInt Shipping in Firefox

#100
post #75

Earlier quoted context omitted.

I love TCL, personally. It's my favorite language to play around in.

Fixed it for you: > I love TCL. > It's my favorite language > to play around in.

Your attempt conflicts with both previous haikus. By their evidence, "TCL" is only two syllables, but you treat it as three.

This does make me curious how they're pronouncing TCL in two syllables, though.

Post reply on HN