Page 1 sur 1

float/"float" converted to integer

Publié : mer. avr. 24, 2019 10:25 pm
par compsystems
Hello

float as a method or function
float(3), float("3") [enter] returns
3.0, 3.0 # ok

the inverse function

integer as a method or function
integer(3.0), integer("3.1"), [enter] returns
set[3] ? # expected 3, 3 =)

Re: float/"float" converted to integer

Publié : sam. avr. 27, 2019 9:38 am
par parisse
The converse of float is int in Python mode, or exact or floor depending what you want to do.

Re: float/"float" converted to integer

Publié : lun. avr. 29, 2019 8:44 pm
par compsystems
Hello BP,

int(5.1) works well. The syntax of python in Xcas should not be exactly the same as that of the python language, but Xcas should have a concordance or similarity in the following.

The words complex, real, integer, rational, float, should be double function: conversion and data type o domain, for example

assume(a, complex)
complex(3, 4) forms a complex 3 + 4 * i
type(3 + 4 * i)> 'complex'

assume(a, real)
real(3 + 4 * i)> 3

assume(a, float)
float(5)> convert to float 5.0

type (5)> 'integer'
integer (5.0) converts to integer, synonymous with int()

assume(a, rational)
rational (0.5)> 1/2 synonym of float2rational (0.5)

that is to say, it is necessary to add two functions synonymous
integer() of int ()
and rational() of float2rational(0.5)