Hello, crystal inherits wisdom from ruby,

but all of a sudden, / and // changes to follow python semantics,

which is quite confusing and why is that?

in ruby // is empty regex, you can try that.

```
puts //
```

Hello, crystal inherits wisdom from ruby,

but all of a sudden, / and // changes to follow python semantics,

which is quite confusing and why is that?

in ruby // is empty regex, you can try that.

```
puts //
```

readed, but it seemed already introduce / and // and donâ€™t discuss

the reason why in first place use / to replace fdiv?

Also another question is

Float64 < BigFloat < BigDecimal,

whatâ€™s difference between BigFloat and BigDecimal,

and why BigFloat < BigDecimal?

Make `/` be float division Â· Issue #2968 Â· crystal-lang/crystal Â· GitHub Sums it up well imo.

My understanding is while `BigFloat`

can handle very large float values, it is not suitable to precise calculations with exact decimal values, which is where `BigDecimal`

comes into play.

`BigFloat`

doesnâ€™t inherit from `BigDecimal`

?

oh, sorry, I mean the link you give me

the first comment,

`And`

max`is computed under the partial order inferred by`

{Float32 < Float64, Float64 < BigFloat < BigDecimal < BigRational, Float64 < Complex}` `

Oh, in that case I donâ€™t think I can really speak to that. Would have to ask Brian to elaborate.

The `<`

relation mentioned in

And

`max`

is computed under the partial order inferred by`{Float32 < Float64, Float64 < BigFloat < BigDecimal < BigRational, Float64 < Complex}`

is not the inheritance. Note that `Float32`

does not inherit from `Float64`

either.

Probably there was a less cryptic way to explain all the rules.

Or be more strict and restrict some operations to operands of the same type.

Am I missing anything else that should be clarified regarding `/`

and `//`

?

yeah, I know you donâ€™t mean inheritance there,

but why BigFloat is partial order < BigDecimal ?

(and donâ€™t worry about symbol here, partial order does use < symbol)

weak partial order is a<=b, strong partial order is a<b)

1.does BigFloat falls within the range of BigDecimal

2. does every number representable by BigFloat also representable by BigDecimal?

`BigFloat`

is an arbitrary-precision integer divided by a power of 2. `BigDecimal`

is an arbitrary-precision integer divided by a power of 10. Therefore every `BigFloat`

is exactly representable by a `BigDecimal`

, although the latter is far less efficient for the same fractional digits. (*GMP* floats are a strict subset of decimals because they cannot represent infinities and not-a-numbers, whereas *MPFR* floats arenâ€™t a strict subset.)

3 Likes