# Converting a Vector{float64} to float{64}

**URL:** <https://discourse.julialang.org/t/converting-a-vector-float64-to-float-64/79953>\
**Category:** New to Julia\
**Created:** [April 24, 2022, 7:12pm UTC](https://discourse.julialang.org/t/converting-a-vector-float64-to-float-64/79953 "2022-04-24T19:12:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_G](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@Will\_G](https://discourse.julialang.org/u/Will_G)\
**Post date:** [April 24, 2022, 7:12pm UTC](https://discourse.julialang.org/t/converting-a-vector-float64-to-float-64/79953/1 "2022-04-24T19:12:25Z")

</div>

I have a one element vector{float64} called “Ge” that operates inside of a for loop. The code I am trying to do is result[num] = (part1+part2)/Ge in which both part 1 and part 2 are type Float64. It doesn’t let me do this because Julia doesn’t allow mathematical operations between Float64 and Vector{float64}. How can I convert any of these variables to make this math operation work?

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [April 24, 2022, 7:14pm UTC](https://discourse.julialang.org/t/converting-a-vector-float64-to-float-64/79953/2 "2022-04-24T19:14:41Z")

</div>

Do you have a reproducible example? What do you expect to happen when you divide a floating point number by a vector?

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [April 24, 2022, 7:21pm UTC](https://discourse.julialang.org/t/converting-a-vector-float64-to-float-64/79953/3 "2022-04-24T19:21:55Z")

</div>

> [@Sukera](#):
>
> Do you have a reproducible example?

I especially like the part where `result[num]` is independent of the rhs.

Edit: OK, enough of our frustrations: the answer is probably broadcasting

```julia
result[num] = (part1+part2)./Ge

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [April 24, 2022, 7:37pm UTC](https://discourse.julialang.org/t/converting-a-vector-float64-to-float-64/79953/4 "2022-04-24T19:37:13Z")

</div>

> [@Will\_G](#):
>
> I have a one element vector{float64} called “Ge”

Perhaps you want to access the single element with` Ge[1]`, so:

> [@Will\_G](#):
>
> result[num] = (part1+part2)/Ge[1]

?

But a MWE would be better to help you. Please consider [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)

---

<div class="post-metadata">

**Author:** ![Will\_G](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@Will\_G](https://discourse.julialang.org/u/Will_G)\
**Post date:** [April 24, 2022, 7:44pm UTC](https://discourse.julialang.org/t/converting-a-vector-float64-to-float-64/79953/5 "2022-04-24T19:44:30Z")

</div>

Ok, I will use MWE’s in the future. Yes, all I had to do was Ge[1] so I could index the exact float value from the vector, thanks for the help

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [April 24, 2022, 7:57pm UTC](https://discourse.julialang.org/t/converting-a-vector-float64-to-float-64/79953/6 "2022-04-24T19:57:25Z")

</div>

You might want `first` or `only`.
