# Does copy() always create a valid copy of BigFloat?

**URL:** <https://discourse.julialang.org/t/does-copy-always-create-a-valid-copy-of-bigfloat/90672>\
**Category:** General Usage\
**Created:** [November 22, 2022, 10:26pm UTC](https://discourse.julialang.org/t/does-copy-always-create-a-valid-copy-of-bigfloat/90672 "2022-11-22T22:26:10Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [November 22, 2022, 11:30pm UTC](https://discourse.julialang.org/t/does-copy-always-create-a-valid-copy-of-bigfloat/90672/6 "2022-11-22T23:30:03Z")

</div>

I found a little faster way for bool^float than [Speed up `x::Bool ^ y::Float64`](https://discourse.julialang.org/t/speed-up-x-bool-y-float64/90601) and decided to tinker a bit with float^bool /

```julia
pow_fast_1(x::T, y::Bool) where T <: AbstractFloat = y ? x : T(1)
pow_fast_2(x::BigFloat, y::Bool) = y ? copy(x) : big(1.0)

```

I found that pow\_fast\_2 is faster than pow\_fast\_1 and native `^` for BigFloat, but copy() in pow\_fast\_2 is not really needed

what do you mean “make PR” ?

---

_[View the full topic](https://discourse.julialang.org/t/does-copy-always-create-a-valid-copy-of-bigfloat/90672)._
