float32

The CandidType object float32 corresponds to the Candid type float32, is inferred to be a TypeScript number, and will be decoded into a JavaScript Number at runtime.

TypeScript or JavaScript:

import { Canister, float32, query } from 'azle';

export default Canister({
    getFloat32: query([], float32, () => {
        return Math.PI;
    }),
    printFloat32: query([float32], float32, (float32) => {
        console.log(typeof float32);
        return float32;
    })
});

Candid:

service : () -> {
    getFloat32 : () -> (float32) query;
    printFloat32 : (float32) -> (float32) query;
}

dfx:

dfx canister call candid_canister printFloat32 '(3.1415927 : float32)'
(3.1415927 : float32)