Thread overview | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 29, 2012 cent and ucent? | ||||
---|---|---|---|---|
| ||||
Hi,
Are there any current plans to implement cent and ucent? I realize no current processors support 128-bit integers natively, but I figure they could be implemented the same way 64-bit integers are on 32-bit machines.
I know I could use std.bigint, but there's no good way to declare a bigint as fixed-size...
--
- Alex
|
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex Rønne Petersen | "Alex Rønne Petersen" <xtzgzorex@gmail.com> wrote in message news:jg26nr$29bh$1@digitalmars.com... > Hi, > > Are there any current plans to implement cent and ucent? I realize no current processors support 128-bit integers natively, but I figure they could be implemented the same way 64-bit integers are on 32-bit machines. > > I know I could use std.bigint, but there's no good way to declare a bigint as fixed-size... > > -- > - Alex There are no current plans that I'm aware of. Implementing cent/ucent would probably require adding support for the type to the backend, and there are a limited number of people that can do that. It's much more likely that phobos will get something like Fixed!128 in addition to BigInt. |
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | Daniel Murphy:
> It's much more likely that phobos will get something like Fixed!128 in addition to BigInt.
Integer numbers have some proprieties that compilers use with built-in fixed-size numbers to optimize code. I think such optimizations are not performed on library-defined numbers like a Fixed!128 or BigInt. This means there are advantages of having cent/ucent/BigInt as built-ins.
Alternatively in theory special annotations are able to tell the compiler that a user-defined type shares some of the characteristics of integer numbers, allowing the compiler to optimize better at compile-time. But I think not even the Scala compiler is so powerful.
Bye,
bearophile
|
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | "bearophile" <bearophileHUGS@lycos.com> wrote in message news:jg2cku$2ljk$1@digitalmars.com... > Integer numbers have some proprieties that compilers use with built-in fixed-size numbers to optimize code. I think such optimizations are not performed on library-defined numbers like a Fixed!128 or BigInt. This means there are advantages of having cent/ucent/BigInt as built-ins. > Yes, but the advantages in implementation ease and portability currently favour a library solution. Do the gcc or llvm backends support 128 bit integers? > Alternatively in theory special annotations are able to tell the compiler that a user-defined type shares some of the characteristics of integer numbers, allowing the compiler to optimize better at compile-time. But I think not even the Scala compiler is so powerful. This would still require backend support for many things. |
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On 29-01-2012 04:38, Daniel Murphy wrote: > "bearophile"<bearophileHUGS@lycos.com> wrote in message > news:jg2cku$2ljk$1@digitalmars.com... >> Integer numbers have some proprieties that compilers use with built-in >> fixed-size numbers to optimize code. I think such optimizations are not >> performed on library-defined numbers like a Fixed!128 or BigInt. This >> means there are advantages of having cent/ucent/BigInt as built-ins. >> > > Yes, but the advantages in implementation ease and portability currently > favour a library solution. > Do the gcc or llvm backends support 128 bit integers? Can't speak for GCC, but LLVM allows arbitrary-size integers. SDC maps cent/ucent to i128. > >> Alternatively in theory special annotations are able to tell the compiler >> that a user-defined type shares some of the characteristics of integer >> numbers, allowing the compiler to optimize better at compile-time. But I >> think not even the Scala compiler is so powerful. > > This would still require backend support for many things. > > Most of LLVM's optimizers work on arbitrary-size ints. -- - Alex |
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On Sunday, January 29, 2012 14:38:41 Daniel Murphy wrote:
> "bearophile" <bearophileHUGS@lycos.com> wrote in message news:jg2cku$2ljk$1@digitalmars.com...
>
> > Integer numbers have some proprieties that compilers use with built-in fixed-size numbers to optimize code. I think such optimizations are not performed on library-defined numbers like a Fixed!128 or BigInt. This means there are advantages of having cent/ucent/BigInt as built-ins.
>
> Yes, but the advantages in implementation ease and portability currently
> favour a library solution.
> Do the gcc or llvm backends support 128 bit integers?
gcc does on 64-bit systems. long long is 128-bit on 64-bit Linux. I don't know about llvm, but it's supposed to be gcc-compatible, so I assume that it's the same.
- Jonathan M Davis
|
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex Rønne Petersen | > gcc does on 64-bit systems. long long is 128-bit on 64-bit Linux. I don't know about llvm, but it's supposed to be gcc-compatible, so I assume that it's the same. > > - Jonathan M Davis > > Can't speak for GCC, but LLVM allows arbitrary-size integers. SDC maps cent/ucent to i128. > > - Alex That's good news. I can't find any information about int128_t in 32 bit gcc, but if the support is already there then it's just the dmd backend that need to be upgraded. |
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On 1/28/2012 8:24 PM, Daniel Murphy wrote:
> That's good news. I can't find any information about int128_t in 32 bit
> gcc, but if the support is already there then it's just the dmd backend that
> need to be upgraded.
There is some support for 128 bit ints already in the backend, but it is incomplete. It's a bit low on the priority list.
|
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Saturday, January 28, 2012 20:41:38 Walter Bright wrote:
> There is some support for 128 bit ints already in the backend, but it is incomplete. It's a bit low on the priority list.
Gotta love the pun there, intended or otherwise... :)
- Jonathan M Davis
|
January 29, 2012 Re: cent and ucent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | "Walter Bright" <newshound2@digitalmars.com> wrote in message news:jg2im4$30qi$1@digitalmars.com... > There is some support for 128 bit ints already in the backend, but it is incomplete. It's a bit low on the priority list. > |
Copyright © 1999-2021 by the D Language Foundation