Jump to page: 1 24  
Page
Thread overview
cent and ucent?
Jan 29, 2012
Daniel Murphy
Jan 29, 2012
bearophile
Jan 29, 2012
Daniel Murphy
Jan 29, 2012
Daniel Murphy
Jan 29, 2012
Walter Bright
Jan 29, 2012
Jonathan M Davis
Jan 29, 2012
Daniel Murphy
Jan 29, 2012
Daniel Murphy
Jan 29, 2012
Walter Bright
Jan 29, 2012
Jonathan M Davis
Jan 29, 2012
Timon Gehr
Jan 29, 2012
Jonathan M Davis
Jan 30, 2012
Walter Bright
Jan 30, 2012
H. S. Teoh
Jan 30, 2012
Daniel Murphy
Jan 30, 2012
Timon Gehr
Jan 30, 2012
H. S. Teoh
Jan 31, 2012
Stewart Gordon
Jan 31, 2012
Marco Leise
Feb 01, 2012
Stewart Gordon
Feb 01, 2012
Walter Bright
Feb 01, 2012
Iain Buclaw
Jan 30, 2012
Marco Leise
Jan 30, 2012
Don Clugston
Feb 01, 2012
Walter Bright
Jan 29, 2012
H. S. Teoh
Jan 30, 2012
Walter Bright
Jan 30, 2012
Jonathan M Davis
Jan 30, 2012
H. S. Teoh
Jan 30, 2012
Iain Buclaw
Jan 30, 2012
Iain Buclaw
Jan 30, 2012
Jonathan M Davis
Jan 30, 2012
Walter Bright
Jan 31, 2012
Stewart Gordon
Mar 29, 2012
ponce
January 29, 2012
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
"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
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
"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
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
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
> 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
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
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
"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.
> 


« First   ‹ Prev
1 2 3 4