mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Error on root of negative number
This commit is contained in:
parent
46510c0b0d
commit
4a182741e0
1 changed files with 3 additions and 0 deletions
|
@ -452,6 +452,9 @@ impl Context {
|
|||
}
|
||||
Ok(base.pow(fexp as i32))
|
||||
} else if (1.0 / fexp).trunc() == 1.0 / fexp {
|
||||
if base.0 < Mpq::zero() {
|
||||
return Err(format!("Root of a negative number is imaginary, which is not yet implemented: {}^{}", self.show(&base), fexp))
|
||||
}
|
||||
base.root((1.0 / fexp) as i32).ok_or(format!("Unit roots must result in integer dimensions"))
|
||||
} else {
|
||||
Err(format!("Exponent not integer"))
|
||||
|
|
Loading…
Reference in a new issue