Re: Is there a 128-bit integer in D?

2016-05-23 Thread Seb via Digitalmars-d-learn

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.


Re: Is there a 128-bit integer in D?

2016-05-22 Thread Era Scarecrow via Digitalmars-d-learn

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.


Re: Is there a 128-bit integer in D?

2016-05-22 Thread Guillaume Piolat via Digitalmars-d-learn

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.


Re: Is there a 128-bit integer in D?

2016-05-22 Thread Era Scarecrow via Digitalmars-d-learn

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!!


Re: Is there a 128-bit integer in D?

2016-05-22 Thread Saurabh Das via Digitalmars-d-learn

On Sunday, 22 May 2016 at 09:07:32 UTC, Guillaume Piolat wrote:

On Sunday, 22 May 2016 at 07:40:08 UTC, Nicholas Wilson wrote:

On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote:
I see that 'cent' and 'ucent' are reserved for future use but 
not yet implemented. Does anyone have a working 
implementation of these types?


Alternatively, is there an any effort towards implementation 
of arbitrary-sized integers in Phobos?


Thanks,
Saurabh


There is a recursive arbitrary sized integer implementation 
floating around somewhere. Perhaps try dub for some math 
libraries.


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 :)

Saurabh



Re: Is there a 128-bit integer in D?

2016-05-22 Thread Guillaume Piolat via Digitalmars-d-learn

On Sunday, 22 May 2016 at 07:40:08 UTC, Nicholas Wilson wrote:

On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote:
I see that 'cent' and 'ucent' are reserved for future use but 
not yet implemented. Does anyone have a working implementation 
of these types?


Alternatively, is there an any effort towards implementation 
of arbitrary-sized integers in Phobos?


Thanks,
Saurabh


There is a recursive arbitrary sized integer implementation 
floating around somewhere. Perhaps try dub for some math 
libraries.


https://github.com/d-gamedev-team/gfm/blob/master/integers/gfm/integers/wideint.d


Re: Is there a 128-bit integer in D?

2016-05-22 Thread Nicholas Wilson via Digitalmars-d-learn

On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote:
I see that 'cent' and 'ucent' are reserved for future use but 
not yet implemented. Does anyone have a working implementation 
of these types?


Alternatively, is there an any effort towards implementation of 
arbitrary-sized integers in Phobos?


Thanks,
Saurabh


There is a recursive arbitrary sized integer implementation 
floating around somewhere. Perhaps try dub for some math 
libraries.


Re: Is there a 128-bit integer in D?

2016-05-22 Thread tcak via Digitalmars-d-learn

On Saturday, 21 May 2016 at 09:56:51 UTC, Stefan Koch wrote:

On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote:
I see that 'cent' and 'ucent' are reserved for future use but 
not yet implemented. Does anyone have a working implementation 
of these types?


Alternatively, is there an any effort towards implementation 
of arbitrary-sized integers in Phobos?


Thanks,
Saurabh


There is BigInt in phobos.


I think cent and ucent could be implemented as ulong is possible 
to be used on 32-bit systems by adding extra assembly 
instructions. This way, when (and if) 128-bit systems are 
developed, compiler would be updated only.


Re: Is there a 128-bit integer in D?

2016-05-21 Thread Saurabh Das via Digitalmars-d-learn

On Saturday, 21 May 2016 at 21:51:34 UTC, Jonathan M Davis wrote:
On Saturday, May 21, 2016 09:43:38 Saurabh Das via 
Digitalmars-d-learn wrote:
I see that 'cent' and 'ucent' are reserved for future use but 
not yet implemented. Does anyone have a working implementation 
of these types?


The keywords are reserved for future use not in current use. 
So, no, there are no 128-bit integer types in D currently. It's 
just that we left the door open for ourselves to add them later 
without breaking programs due to having to create a new keyword.


Alternatively, is there an any effort towards implementation 
of arbitrary-sized integers in Phobos?


We've had that for years. It's BigInt in std.bigint.

- Jonathan M Davis


Thankyou. I'll have a look at that.

Saurabh


Re: Is there a 128-bit integer in D?

2016-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 21, 2016 09:43:38 Saurabh Das via Digitalmars-d-learn wrote:
> I see that 'cent' and 'ucent' are reserved for future use but not
> yet implemented. Does anyone have a working implementation of
> these types?

The keywords are reserved for future use not in current use. So, no, there
are no 128-bit integer types in D currently. It's just that we left the door
open for ourselves to add them later without breaking programs due to having
to create a new keyword.

> Alternatively, is there an any effort towards implementation of
> arbitrary-sized integers in Phobos?

We've had that for years. It's BigInt in std.bigint.

- Jonathan M Davis



Re: Is there a 128-bit integer in D?

2016-05-21 Thread Stefan Koch via Digitalmars-d-learn

On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote:
I see that 'cent' and 'ucent' are reserved for future use but 
not yet implemented. Does anyone have a working implementation 
of these types?


Alternatively, is there an any effort towards implementation of 
arbitrary-sized integers in Phobos?


Thanks,
Saurabh


There is BigInt in phobos.