小编kun*_*255的帖子

为什么不发生浮点异常?

我正在学习浮点数的算法.我写了下面的代码.但是不会发生浮点异常.我的环境是Cent OS 6.4(x86_64).

请教我这个理由.

#include <stdio.h>

int
main(void)
{
  double a,b,c;
  unsigned short int fctr;

  a=3.0;
  b=0.0;
  c=1.0;

  asm volatile(
    "fstcw %w0" // get FPU control word
    :"=m"(fctr):);
  printf("FPU control word= %X\n", fctr);

  fctr = fctr ^ 0x4;
  printf("FPU control word= %X\n", fctr);

  asm volatile(
    "fldcw %w0"  // set operand to FPU control word
    : :"m"(fctr));

  asm volatile(
    "fstcw %w0" // get FPU control word
    :"=m"(fctr):);
  printf("FPU control word= %X\n", fctr);

  c = a/b;

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

linux assembly x86-64 fpu sigfpe

2
推荐指数
1
解决办法
259
查看次数

无法从iOS模拟器获取位置

我试图通过简单的快速代码使用iOS模拟器获得位置.但是在调试会话中,不会调用回调函数.我将虚拟位置设置为iOS模拟器.

//  ViewController.swift
//  helloWorld
//
//  Created by  on 5/17/15.
//  Copyright (c) 2015   All rights reserved.
//

import UIKit
import CoreLocation

class ViewController: UIViewController, CLLocationManagerDelegate {

    var locMan: CLLocationManager!
    var lat: CLLocationDegrees!
    var lng: CLLocationDegrees!
    var hasPosData: Bool

    required init(coder aDecoder: NSCoder) {
        locMan  = CLLocationManager()
        lat = CLLocationDegrees()
        lng = CLLocationDegrees()
        hasPosData = false
        super.init(coder: aDecoder)
    }

    func retreiveCurrentPos(){
        locMan.delegate = self
        locMan.requestAlwaysAuthorization()

        // start using GPS function
        locMan.startUpdatingLocation()
    }

    func saveResult2File(){
        var contents: String

        let dirToSave …
Run Code Online (Sandbox Code Playgroud)

core-location ios swift

-1
推荐指数
1
解决办法
1023
查看次数

标签 统计

assembly ×1

core-location ×1

fpu ×1

ios ×1

linux ×1

sigfpe ×1

swift ×1

x86-64 ×1