## D - Is this is intentional (or a bug)? (1/3 equals 0)

• SL (16/16) Mar 26 2004 Basically, I wrote this out:
• Ilya Minkov (6/29) Mar 26 2004 It is a C-ism. Due to lack of proper beginners' books on D, it is very
• Stewart Gordon (11/18) Mar 26 2004 I think so.
```Basically, I wrote this out:

And radius was coming out to 1 every time. So I made a printf to show
various parts of that.

.toString(PI), .toString(volume), .toString((volume*3)/(4*PI)),

And then I did this:
printf("1/3=%.*s",.toString(1/3));

And got:
1/3=0

I suppose this is intentional (Since both numbers are integers)?

P.S. I have changed it to 1/3.0, which works, but does not look like a
proper fraction :P.
-SL
```
Mar 26 2004
Ilya Minkov <minkov cs.tum.edu> writes:
```It is a C-ism. Due to lack of proper beginners' books on D, it is very
advantageous to learn some of C before going to D. Also, everything
which works the same way as in C or C++ has been left out of the
documentation.

-eye

SL schrieb:
Basically, I wrote this out:

And radius was coming out to 1 every time. So I made a printf to show
various parts of that.

.toString(PI), .toString(volume), .toString((volume*3)/(4*PI)),

And then I did this:
printf("1/3=%.*s",.toString(1/3));

And got:
1/3=0

I suppose this is intentional (Since both numbers are integers)?

P.S. I have changed it to 1/3.0, which works, but does not look like a
proper fraction :P.
-SL

```
Mar 26 2004
Stewart Gordon <smjg_1998 yahoo.com> writes:
```SL wrote:

<snip>
And got:
1/3=0

I suppose this is intentional (Since both numbers are integers)?

I think so.

P.S. I have changed it to 1/3.0, which works, but does not look like a
proper fraction :P.
-SL

Does

cast(real) 1/3

look more like it to you?

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment.  Please keep
replies on the 'group where everyone may benefit.
```
Mar 26 2004