May 22, 2016 Re: Is there a 128-bit integer in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Guillaume Piolat | On Sunday, 22 May 2016 at 12:03:16 UTC, Guillaume Piolat wrote:
> I don't know how this works, someone has to propose it, clean it up and respond to feedback I guess.
Glancing briefly at the source, it appears (from what I saw) it's heavily based on doubling the size of a lower type (2 64's to equal a 128, etc). This means to get the next level up you double again. So if I read it right for example, the opIncrease does this almost verbatim:
opIncrease() { //aka ++
low++;
if (low == 0) //overflow detection
high++;
}
Going from native up one level is easy enough, but to do a 256 type it would do the same from a lower level. Meaning the int256 type does opIncrease on 2 int128 types, which break down to the native long type. Making a 256 or 512 silently creates all the lower ones until it can lower to a native type as the starting point.
More importantly is if they fully act as built-in types with their declarations, except (for maybe auto promotion of course, although that might work too). The only two operations that are going to be slow no matter how you slice it are multiply and divide. If you don't use multiply or divide, your code will be fast regardless how many levels it goes.
|
May 23, 2016 Re: Is there a 128-bit integer in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Guillaume Piolat | On Sunday, 22 May 2016 at 12:03:16 UTC, Guillaume Piolat wrote: > On Sunday, 22 May 2016 at 09:47:54 UTC, Era Scarecrow wrote: >> On Sunday, 22 May 2016 at 09:39:45 UTC, Saurabh Das wrote: >>> On Sunday, 22 May 2016 at 09:07:32 UTC, Guillaume Piolat wrote: >>>> https://github.com/d-gamedev-team/gfm/blob/master/integers/gfm/integers/wideint.d >>> >>> wideint was exactly what I was looking for! Thank you so much :) >> >> I WANT! If this does the job, I want it as part of the Phobos library!! > > This request again ;) > I don't know how this works, someone has to propose it, clean it up and respond to feedback I guess. 1) Open PR for initial review 2) Select review manager (from the inital reviewers) 3) Open NG thread and add the addition to the queue (http://wiki.dlang.org/Review_Queue) 4) Hope for positive feedback In the last month there was a tendency to only accept successful dub packages, so it might make sense to separate this into its own dub package and clean it up. This will also make it easier for other people to find. |
Copyright © 1999-2021 by the D Language Foundation