![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Adding in PowerShell I know this is going to be simple.. but say I have a $Sum = 10 and I want $Total = $Sum+.10 I've also tried $Total = ($Sum + .10) and Ive tried $diff = .10 with $Total = ($Sum + $Diff) without success.. What did I do wrong? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Adding in PowerShell This works for me. PS> $Sum = 10 PS> $Total = $Sum + .10 PS> $Total 10.1 Are you getting an error message? NeilOz wrote: Quote: > I know this is going to be simple.. but say I have a $Sum = 10 and I want > $Total = $Sum+.10 > I've also tried $Total = ($Sum + .10) and Ive tried $diff = .10 with $Total > = ($Sum + $Diff) without success.. > > What did I do wrong? |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Adding in PowerShell Nope no error message, What I'm doing is downloading the results from a web service into an xml string using [xml]$Quote = $Webclient.DownloadString("http://server:1891/MarketInfoService.asmx/LiveQuote?Code="+$StockCode) $BestBuy = $Quote.Quote.BestSellPrice I get the desired result from $BestBuy which is say 10.00 But when I run $BuyPrice = $BestBuy + .10 I get $BuyPrice = 10.00.10 "Mark E. Schill" wrote: Quote: > This works for me. > > PS> $Sum = 10 > PS> $Total = $Sum + .10 > PS> $Total > 10.1 > > Are you getting an error message? > > > > NeilOz wrote: Quote: > > I know this is going to be simple.. but say I have a $Sum = 10 and I want > > $Total = $Sum+.10 > > I've also tried $Total = ($Sum + .10) and Ive tried $diff = .10 with $Total > > = ($Sum + $Diff) without success.. > > > > What did I do wrong? |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Adding in PowerShell That's because $BestBuy is a string, so PowerShell is performing string concatenation when you use it with the + operator. To get a numeric value you need to typecast $BestBuy (e.g $BuyPrice = [double]$BestBuy + .10). -- Kirk Munro [MVP] Poshoholic http://poshoholic.com "NeilOz" <NeilOz@xxxxxx> wrote in message news CC78F21-CE95-4C34-B522-A423FCA6CD2C@xxxxxxQuote: > Nope no error message, What I'm doing is downloading the results from a > web > service into an xml string using > > [xml]$Quote = > $Webclient.DownloadString("http://server:1891/MarketInfoService.asmx/LiveQuote?Code="+$StockCode) > > $BestBuy = $Quote.Quote.BestSellPrice > > I get the desired result from $BestBuy which is say 10.00 > But when I run $BuyPrice = $BestBuy + .10 > I get $BuyPrice = 10.00.10 > > "Mark E. Schill" wrote: > Quote: >> This works for me. >> >> PS> $Sum = 10 >> PS> $Total = $Sum + .10 >> PS> $Total >> 10.1 >> >> Are you getting an error message? >> >> >> >> NeilOz wrote: Quote: >> > I know this is going to be simple.. but say I have a $Sum = 10 and I >> > want >> > $Total = $Sum+.10 >> > I've also tried $Total = ($Sum + .10) and Ive tried $diff = .10 with >> > $Total >> > = ($Sum + $Diff) without success.. >> > >> > What did I do wrong? |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| PowerShell - adding security group | PowerShell | |||
| PowerShell Leaders Join Forces and offer a pre-release version of PowerShell for 50% off the retail value | PowerShell | |||
| Info: Adding books to Powershell Site | PowerShell | |||
| Adding Promise FastTrack 378 Adding | Vista hardware & devices | |||
| Adding Promise FastTrack 378 Adding | Vista hardware & devices | |||