On Monday, 8 May 2023 at 04:13:11 UTC, NonNull wrote:
On Monday, 8 May 2023 at 03:22:02 UTC, anonymouse wrote:
Never thought I'd have to do this but, in Python:

```Python
pow(1/2, 3)
```
output:
```
 0.125
```
in D:

```D
import std.stdio;
void main()
{
  writeln((1/2)^^3);
}

Using DMD64 D Compiler v2.103.0:

The above program ran and output ```0``` because ```1/2``` is zero in D as that's integer division. Putting 1.0 instead of 1, it output ```0.125```.

Your compiler version is?

Fare enough regarding integer division, I used 1/2 in python when I switch to check my sanity and carried it forward when I came back to D but the results were the exact same. Errors vice the outputs you posted above. The actual code that triggered this was
```D
double d = 0.5;
int n = 3;
writeln(d ^^ n);
```
As for the version of D I'm using, according to ```dmd --version``` it is none other than

DMD64 D Compiler v2.103.0

Not sure if it makes a difference but I'm using MacOS Ventura.

Reply via email to