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 =)
float/"float" converted to integer
Modérateur : xcasadmin
-
- Messages : 562
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: float/"float" converted to integer
The converse of float is int in Python mode, or exact or floor depending what you want to do.
-
- Messages : 562
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: float/"float" converted to integer
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)
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)