fmg
fmg

Reputation: 925

Absolute value of float in ocaml

When I use the function abs_float, Merlin (running in emacs) tells me:

Warning 3: deprecated: Core.Std.abs_float [since 2014-10] Use [Float]

(The code still compiles, though.) What is this trying to tell me? I've tried Float.abs and similar variants without success. When I try #require "Float" and open Float in utop, I get No such package and unbound module errors.

I know it's trivial to write an absolute value function oneself, but I'm still interested in knowing how to do this the "right" way.

Upvotes: 2

Views: 574

Answers (2)

Nick Zuber
Nick Zuber

Reputation: 5637

What is this trying to tell me?

The warning message that you're getting:

Warning 3: deprecated: Core.Std.abs_float

is telling you that the function abs_float has been deprecated. This basically means that, while the function still works, it's no longer supported and advises you to not use it anymore.

When you see the message

Use [Float]

It's telling you that the newer version that you should be using is in the Float module. This is in the context of Core.Std, so instead of using

Core.Std.abs_float

you should use

Core.Std.Float.abs

Upvotes: 2

Pierre G.
Pierre G.

Reputation: 4441

The answer is :

 Core.Std.Float.abs (-6.0)

Upvotes: 3

Related Questions